/* Naaganna PWA Styles
   Designed for farmers on mobile phones
   Large touch targets, high contrast, simple layout */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --green-dark:  #1a4a1a;
    --green-main:  #2d6a2d;
    --green-light: #4a9e4a;
    --green-pale:  #e8f5e8;
    --gold:        #f0a500;
    --text-dark:   #1a1a1a;
    --text-mid:    #444444;
    --text-light:  #777777;
    --white:       #ffffff;
    --red:         #c0392b;
    --shadow:      0 2px 12px rgba(0,0,0,0.12);
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Noto Sans Telugu', 'Noto Sans', sans-serif;
    background: var(--green-pale);
    color: var(--text-dark);
}

/* ── Header ────────────────────────────────────────── */
.header {
    background: var(--green-main);
    color: var(--white);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
    position: relative;
    z-index: 10;
}

.header-icon {
    font-size: 28px;
}

.header-text h1 {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
}

.header-text p {
    font-size: 12px;
    opacity: 0.85;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #aaa;
    transition: background 0.3s;
}

.status-dot.online  { background: #4caf50; }
.status-dot.error   { background: var(--red); }

.version-badge {
    font-size: 10px;
    color: rgba(255,255,255,0.6);
    margin-left: auto;
    margin-right: 6px;
    font-weight: 400;
}

/* ── Main Content ──────────────────────────────────── */
.main {
    position: absolute;
    top: 64px;
    bottom: 160px;
    left: 0;
    right: 0;
    overflow-y: auto;
    padding: 12px;
    -webkit-overflow-scrolling: touch;
}

/* ── Welcome Screen ────────────────────────────────── */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 20px;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: sway 3s ease-in-out infinite;
}

@keyframes sway {
    0%, 100% { transform: rotate(-5deg); }
    50%       { transform: rotate(5deg); }
}

.welcome-text {
    font-size: 20px;
    line-height: 1.8;
    color: var(--green-dark);
    font-weight: 500;
    margin-bottom: 16px;
}

.welcome-hint {
    font-size: 14px;
    color: var(--text-light);
}

/* ── Conversation ──────────────────────────────────── */
.conversation {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 90%;
    padding: 12px 14px;
    border-radius: 16px;
    line-height: 1.7;
    font-size: 16px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.message.farmer {
    background: var(--white);
    border: 1px solid #ddd;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    color: var(--text-mid);
    font-size: 14px;
}

.message.naaganna {
    background: var(--green-main);
    color: var(--white);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.error {
    background: #fdecea;
    border: 1px solid #f5c6cb;
    color: var(--red);
    align-self: center;
    text-align: center;
    font-size: 14px;
}

.message-image {
    width: 100%;
    max-width: 200px;
    border-radius: 10px;
    margin-bottom: 8px;
    display: block;
}

.play-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 20px;
    color: white;
    padding: 6px 14px;
    margin-top: 8px;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.play-btn:active {
    background: rgba(255,255,255,0.3);
}

/* ── Loading ────────────────────────────────────────── */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px;
    color: var(--text-light);
    font-size: 15px;
}

.loading-dots {
    display: flex;
    gap: 6px;
}

.loading-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--green-main);
    animation: bounce 1.2s infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40%           { transform: scale(1.2); opacity: 1; }
}

/* ── Recording Bar ─────────────────────────────────── */
.recording-bar {
    position: fixed;
    bottom: 130px;
    left: 12px;
    right: 12px;
    background: var(--red);
    color: white;
    border-radius: 12px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

.recording-pulse {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    animation: pulse 1s infinite;
    flex-shrink: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.8); }
}

.recording-timer {
    margin-left: auto;
    font-size: 13px;
    opacity: 0.9;
}

/* ── Action Buttons ────────────────────────────────── */
.actions {
    position: fixed;
    bottom: 28px;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 12px 8px 8px;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
    z-index: 50;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 14px;
    transition: background 0.15s;
    min-width: 72px;
    user-select: none;
}

.action-btn:active {
    background: var(--green-pale);
}

.btn-icon {
    font-size: 28px;
}

.btn-label {
    font-size: 12px;
    color: var(--text-mid);
    font-weight: 500;
}

/* Mic button — highlighted as primary action */
.mic-btn {
    background: var(--green-main);
    padding: 12px 24px;
}

.mic-btn .btn-icon { font-size: 32px; }

.mic-btn .btn-label {
    color: var(--white);
    font-size: 13px;
}

.mic-btn.recording {
    background: var(--red);
    animation: glow 1s infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(192,57,43,0.4); }
    50%       { box-shadow: 0 0 0 8px rgba(192,57,43,0); }
}

.mic-btn.disabled {
    background: #aaa;
    pointer-events: none;
}

/* ── Image Preview ─────────────────────────────────── */
.image-preview {
    position: fixed;
    bottom: 130px;
    right: 12px;
    width: 72px;
    height: 72px;
    border-radius: 12px;
    overflow: hidden;
    border: 3px solid var(--green-main);
    box-shadow: var(--shadow);
    z-index: 100;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-image {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 4px 8px;
    font-size: 10px;
    color: #999;
    background: #f0f0f0;
    border-top: 1px solid #e0e0e0;
    z-index: 40;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}