
/* ==========================================
   YOUR FARMER - AI CHATBOT DESIGN
   ========================================== */

:root {
    --green-950: #102d20;
    --green-900: #153c2b;
    --green-800: #20543a;
    --green-700: #28734b;
    --green-600: #368b59;
    --green-100: #e8f3e9;
    --green-50: #f5faf5;

    --background: #ffffff;
    --surface: #f8faf8;
    --border: #e5ebe5;
    --text: #202b23;
    --muted: #78847b;

    --sidebar-width: 270px;
    --radius: 14px;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, Helvetica, Arial, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background: var(--background);
    color: var(--text);
    overflow: hidden;
}

button,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--green-600);
    outline-offset: 3px;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ==========================================
   SIDEBAR
   ========================================== */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 22px 16px 16px;
    background: #f7faf7;
    border-right: 1px solid var(--border);
    transition: transform 0.25s ease;
    z-index: 20;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    padding: 0 5px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--green-950);
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.brand-icon {
    display: grid;
    place-items: center;
    width: 37px;
    height: 37px;
    background: var(--green-100);
    border-radius: 11px;
    font-size: 21px;
}

.new-chat-button {
    width: 100%;
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 11px;
    padding: 0 14px;
    background: var(--green-900);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s ease, transform 0.2s ease;
}

.new-chat-button:hover {
    background: var(--green-700);
    transform: translateY(-1px);
}

.new-chat-button span {
    font-size: 22px;
    font-weight: 400;
}

.sidebar-menu {
    margin-top: 30px;
}

.menu-heading {
    padding: 0 10px;
    margin-bottom: 12px;
    color: #849087;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.3px;
}

.menu-link {
    min-height: 43px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    margin-bottom: 4px;
    color: #536258;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: 9px;
    transition: all 0.2s ease;
}

.menu-link:hover {
    background: #eaf2eb;
    color: var(--green-900);
}

.menu-link.active {
    background: #e5f0e6;
    color: var(--green-900);
    font-weight: 700;
}

.history-section {
    flex: 1;
    min-height: 0;
    margin-top: 32px;
    overflow-y: auto;
}

.empty-history {
    padding: 8px 10px;
    color: #9aa49d;
    font-size: 12px;
    line-height: 1.6;
}

.chat-history {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.history-item {
    width: 100%;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: #59665d;
    font-size: 12px;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item:hover {
    background: #eaf2eb;
}

.sidebar-footer {
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 7px;
}

.profile-avatar {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    background: var(--green-800);
    color: white;
    border-radius: 50%;
    font-weight: 700;
}

.user-profile strong,
.user-profile small {
    display: block;
}

.user-profile strong {
    font-size: 12px;
    color: var(--text);
}

.user-profile small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 10px;
}

/* ==========================================
   MAIN CONTENT
   ========================================== */

.main-content {
    flex: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

.topbar {
    height: 66px;
    min-height: 66px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid #edf0ed;
    background: rgba(255, 255, 255, 0.96);
}

.topbar-title {
    color: var(--green-950);
    font-size: 14px;
    font-weight: 700;
}

.icon-button {
    width: 37px;
    height: 37px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: #536258;
    font-size: 18px;
}

.icon-button:hover {
    background: var(--green-100);
}

.menu-toggle,
.mobile-close {
    display: none;
}

.language-control {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: white;
}

.language-control select {
    max-width: 125px;
    border: none;
    outline: none;
    background: transparent;
    color: #445349;
    font-size: 12px;
    cursor: pointer;
}

/* ==========================================
   CHAT AREA
   ========================================== */

.chat-area {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow-y: auto;
    padding: 35px 24px;
}

.welcome-screen {
    width: 100%;
    max-width: 750px;
    margin: 55px auto 40px;
    text-align: center;
}

.welcome-icon {
    width: 70px;
    height: 70px;
    display: grid;
    place-items: center;
    margin: 0 auto 23px;
    background: #eaf4e9;
    border: 1px solid #dcebdc;
    border-radius: 22px;
    font-size: 37px;
}

.welcome-label {
    margin-bottom: 15px;
    color: var(--green-700);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 2px;
}

.welcome-screen h1 {
    color: var(--green-950);
    font-size: clamp(32px, 5vw, 48px);
    line-height: 1.17;
    letter-spacing: -1.8px;
    font-weight: 750;
}

.welcome-screen h1 span {
    color: var(--green-600);
}

.welcome-description {
    max-width: 480px;
    margin: 18px auto 32px;
    color: #77837a;
    font-size: 14px;
    line-height: 1.8;
}

/* ==========================================
   SUGGESTED QUESTIONS
   ========================================== */

.suggestion-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    max-width: 620px;
    margin: 0 auto;
}

.suggestion-card {
    min-height: 105px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 15px 17px;
    border: 1px solid #e7eee7;
    border-radius: 12px;
    background: white;
    text-align: left;
    transition: all 0.2s ease;
}

.suggestion-card:hover {
    border-color: #9bbca0;
    background: #f7fbf7;
    transform: translateY(-2px);
    box-shadow: 0 5px 16px rgba(25, 70, 40, 0.06);
}

.suggestion-card span {
    margin-bottom: 8px;
    font-size: 21px;
}

.suggestion-card strong {
    margin-bottom: 5px;
    color: #34443a;
    font-size: 12px;
}

.suggestion-card small {
    color: #849087;
    font-size: 11px;
}

/* ==========================================
   CHAT MESSAGES
   ========================================== */

.messages-container {
    width: 100%;
    max-width: 790px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.message {
    display: flex;
    gap: 12px;
    width: 100%;
    align-items: flex-start;
}

.message.user-message {
    justify-content: flex-end;
}

.message-avatar {
    width: 33px;
    height: 33px;
    min-width: 33px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: var(--green-100);
    font-size: 17px;
}

.message-content {
    max-width: 82%;
    padding: 13px 16px;
    border-radius: 13px;
    background: #f4f7f4;
    color: #354239;
    font-size: 14px;
    line-height: 1.75;
    overflow-wrap: anywhere;
}

.user-message .message-content {
    background: var(--green-900);
    color: white;
    border-radius: 13px 13px 3px 13px;
}

.ai-message .message-content {
    border-radius: 3px 13px 13px 13px;
}

.message-content img {
    max-width: 220px;
    max-height: 180px;
    display: block;
    margin-top: 10px;
    border-radius: 9px;
}

.typing-indicator {
    color: var(--green-700);
    font-size: 13px;
    padding: 10px 0;
}

/* ==========================================
   MESSAGE COMPOSER
   ========================================== */

.composer-section {
    width: 100%;
    max-width: 850px;
    padding: 12px 24px 18px;
    margin: 0 auto;
    background: white;
}

.message-form {
    width: 100%;
    min-height: 61px;
    display: flex;
    align-items: flex-end;
    gap: 9px;
    padding: 10px 12px;
    border: 1px solid #dce5dc;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 5px 22px rgba(25, 60, 35, 0.06);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.message-form:focus-within {
    border-color: #82ad89;
    box-shadow: 0 5px 25px rgba(40, 115, 75, 0.10);
}

.message-form textarea {
    flex: 1;
    min-width: 0;
    max-height: 140px;
    min-height: 35px;
    padding: 9px 2px;
    resize: none;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
}

.message-form textarea::placeholder {
    color: #9aa59c;
}

.composer-button {
    width: 36px;
    height: 36px;
    min-width: 36px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 9px;
    background: #f0f5f0;
    color: var(--green-800);
    font-size: 19px;
    transition: background 0.2s ease;
}

.composer-button:hover {
    background: #e1eee2;
}

.voice-button {
    font-size: 17px;
}

.send-button {
    width: 37px;
    height: 37px;
    min-width: 37px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 10px;
    background: var(--green-800);
    color: white;
    font-size: 19px;
    transition: background 0.2s ease, transform 0.2s ease;
}

.send-button:hover {
    background: var(--green-600);
    transform: scale(1.04);
}

.composer-note {
    margin-top: 12px;
    color: #99a29b;
    font-size: 10px;
    text-align: center;
    line-height: 1.5;
}

.upload-preview {
    margin-top: 8px;
    color: var(--green-700);
    font-size: 12px;
    text-align: center;
}

/* ==========================================
   SCROLLBAR
   ========================================== */

.chat-area::-webkit-scrollbar,
.history-section::-webkit-scrollbar {
    width: 5px;
}

.chat-area::-webkit-scrollbar-thumb,
.history-section::-webkit-scrollbar-thumb {
    background: #dce6dc;
    border-radius: 10px;
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 900px) {
    :root {
        --sidebar-width: 245px;
    }

    .welcome-screen {
        margin-top: 35px;
    }

    .topbar {
        padding: 0 18px;
    }
}

@media (max-width: 650px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 275px;
        min-width: 275px;
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 35px rgba(0, 0, 0, 0.12);
    }

    .menu-toggle,
    .mobile-close {
        display: grid;
    }

    .topbar {
        height: 58px;
        min-height: 58px;
        padding: 0 12px;
        gap: 10px;
    }

    .topbar-title {
        flex: 1;
        font-size: 12px;
    }

    .language-control {
        padding: 6px;
    }

    .language-control select {
        max-width: 90px;
        font-size: 11px;
    }

    .chat-area {
        padding: 20px 14px;
    }

    .welcome-screen {
        margin: 35px auto 25px;
    }

    .welcome-icon {
        width: 60px;
        height: 60px;
        font-size: 31px;
    }

    .welcome-screen h1 {
        font-size: 34px;
        letter-spacing: -1px;
    }

    .welcome-description {
        font-size: 12px;
        margin: 15px auto 25px;
    }

    .suggestion-grid {
        gap: 9px;
    }

    .suggestion-card {
        min-height: 105px;
        padding: 12px;
    }

    .suggestion-card strong {
        font-size: 11px;
    }

    .suggestion-card small {
        font-size: 10px;
    }

    .composer-section {
        padding: 8px 10px 12px;
    }

    .message-form {
        min-height: 55px;
        gap: 6px;
        padding: 8px;
    }

    .message-form textarea {
        font-size: 12px;
    }

    .composer-button {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    .send-button {
        width: 34px;
        height: 34px;
        min-width: 34px;
    }

    .composer-note {
        font-size: 9px;
    }

    .message-content {
        max-width: 88%;
        font-size: 13px;
    }
}

@media (max-width: 360px) {
    .suggestion-grid {
        grid-template-columns: 1fr;
    }

    .welcome-screen h1 {
        font-size: 29px;
    }
}


/* ==========================================
   FARMER AUTHENTICATION
   ========================================== */

.auth-button {
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid #dce8dd;
    border-radius: 9px;
    background: #f5faf5;
    color: var(--green-900);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.auth-button:hover {
    background: #e8f3e9;
}

.auth-modal[hidden] {
    display: none;
}

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 18px;
}

.auth-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 30, 19, 0.58);
    backdrop-filter: blur(3px);
}

.auth-dialog {
    position: relative;
    width: min(100%, 430px);
    max-height: min(92vh, 720px);
    overflow-y: auto;
    padding: 34px;
    border: 1px solid #e4ece4;
    border-radius: 19px;
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
}

.auth-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 9px;
    background: #f2f6f2;
    color: #536258;
    font-size: 16px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 27px;
    color: var(--green-950);
    font-size: 14px;
    font-weight: 800;
}

.auth-brand span {
    font-size: 23px;
}

.auth-eyebrow {
    margin-bottom: 8px;
    color: var(--green-700);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
}

.auth-dialog h2 {
    margin-bottom: 9px;
    color: var(--green-950);
    font-size: 25px;
    letter-spacing: -0.6px;
}

.auth-description {
    margin-bottom: 23px;
    color: #77837a;
    font-size: 13px;
    line-height: 1.6;
}

.auth-label {
    display: block;
    margin: 14px 0 7px;
    color: #445349;
    font-size: 12px;
    font-weight: 700;
}

.auth-input {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid #dce5dc;
    border-radius: 9px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    font-size: 13px;
}

.auth-input:focus {
    outline: 2px solid #a9c9ad;
    outline-offset: 1px;
    border-color: var(--green-600);
}

.auth-error {
    min-height: 18px;
    margin-top: 10px;
    color: #b42318;
    font-size: 12px;
    line-height: 1.5;
}

.auth-submit {
    width: 100%;
    min-height: 45px;
    margin-top: 8px;
    border: 0;
    border-radius: 10px;
    background: var(--green-900);
    color: white;
    font-size: 13px;
    font-weight: 700;
}

.auth-submit:hover {
    background: var(--green-700);
}

.auth-submit:disabled {
    cursor: wait;
    opacity: 0.7;
}

.auth-switch {
    width: 100%;
    margin-top: 17px;
    padding: 8px;
    border: 0;
    background: transparent;
    color: var(--green-800);
    font-size: 12px;
    font-weight: 700;
}

.auth-footnote {
    margin-top: 17px;
    color: #8a958d;
    font-size: 10px;
    line-height: 1.5;
    text-align: center;
}

@media (max-width: 650px) {
    .auth-button {
        min-height: 33px;
        padding: 0 10px;
        font-size: 11px;
    }

    .auth-dialog {
        padding: 28px 22px;
    }
}
