/* Premium Design Tokens */
:root {
    --bg-primary: #fafbfa;
    --bg-secondary: #f3f5f2;
    --sidebar-bg: #ffffff;
    --border-color: rgba(21, 128, 61, 0.12);
    --border-focus: #15803d;
    --primary-accent: #0f1d13;
    --primary-green: #15803d;
    --primary-green-soft: rgba(21, 128, 61, 0.06);
    --primary-green-glow: rgba(21, 128, 61, 0.15);
    --text-main: #142217;
    --text-muted: #57655b;
    --shadow-premium: 0 4px 20px rgba(15, 29, 19, 0.03);
    --shadow-heavy: 0 10px 30px rgba(15, 29, 19, 0.06);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--bg-primary);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling - Clean & Premium */
.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 30px 20px 20px 20px;
    display: flex;
    flex-direction: column;
    transition: var(--transition-smooth);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.015);
    z-index: 10;
}

.sidebar-scroll {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 25px;
    padding-right: 4px;
    margin-top: 15px;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 4px;
}
.sidebar-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-scroll::-webkit-scrollbar-thumb {
    background: var(--bg-secondary);
    border-radius: 10px;
}
.sidebar-scroll::-webkit-scrollbar-thumb:hover {
    background: #d1d8d4;
}

/* Logo Styling */
.logo-container {
    text-align: center;
    margin-bottom: 10px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.ccd-logo {
    max-width: 130px;
    height: auto;
    filter: brightness(0.9);
}

/* Crop Diary Styling - High Craft Cards */
.diary-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-subtitle {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary-green);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.diary-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 2px;
}

.diary-list::-webkit-scrollbar {
    width: 4px;
}
.diary-list::-webkit-scrollbar-thumb {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.diary-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    overflow: hidden;
}

.diary-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-green);
    opacity: 0;
    transition: var(--transition-smooth);
}

.diary-item:hover {
    background: var(--sidebar-bg);
    border-color: var(--primary-green);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(21, 128, 61, 0.05);
}

.diary-item:hover::before {
    opacity: 1;
}

.diary-item-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

.diary-item-title {
    font-weight: 600;
    color: var(--primary-accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.85rem;
}

.empty-diary {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    padding: 20px 0;
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
}

/* Custom Sprayer Calculator - Stunning HSL styling */
.calculator-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.calc-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-accent);
}

.calc-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.slider-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 5px 0;
}

.calc-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 10px;
    background: #e1e7e3;
    outline: none;
    transition: var(--transition-smooth);
}

.calc-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-green);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(21, 128, 61, 0.2);
    transition: var(--transition-smooth);
    border: 2px solid #ffffff;
}

.calc-slider::-webkit-slider-thumb:hover {
    background: var(--primary-accent);
    transform: scale(1.15);
}

.slider-value {
    text-align: right;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-green);
}

.calc-results {
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow-premium);
}

.result-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.result-row strong {
    color: var(--primary-accent);
    font-weight: 700;
}

/* Chat Area Styling - Spaced & High fidelity */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 30px;
    border-bottom: 1px solid var(--border-color);
    background: var(--sidebar-bg);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.005);
}

.header-left {
    display: flex;
    align-items: center;
}

.menu-btn {
    background: var(--bg-secondary);
    border: none;
    color: var(--primary-accent);
    font-size: 1.3rem;
    cursor: pointer;
    margin-right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.menu-btn:hover {
    background: var(--border-color);
}

.main-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-accent);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 12px;
    border-left: 1px solid var(--border-color);
    padding-left: 12px;
}

/* Premium Language Toggle Switch */
.lang-toggle {
    display: flex;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
}

.lang-pill {
    background: transparent;
    border: none;
    padding: 6px 16px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition-smooth);
}

.lang-pill.active {
    background: #ffffff;
    color: var(--primary-green);
    box-shadow: 0 2px 8px rgba(21, 128, 61, 0.08);
}

/* Chat Feed Window */
.chat-box {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 25px;
    scroll-behavior: smooth;
}

.chat-box::-webkit-scrollbar {
    width: 4px;
}
.chat-box::-webkit-scrollbar-thumb {
    background: var(--bg-secondary);
    border-radius: 10px;
}

/* Messaging Bubbles - Absolute Perfection */
.message {
    display: flex;
    width: 100%;
}

.message.user {
    justify-content: flex-end;
}

.message.ai {
    justify-content: flex-start;
}

.bubble {
    max-width: 70%;
    padding: 16px 20px;
    border-radius: 16px;
    line-height: 1.6;
    font-size: 0.95rem;
    font-weight: 400;
    box-shadow: var(--shadow-premium);
}

.message.ai .bubble {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary-green);
    border-top-left-radius: 4px;
    color: var(--text-main);
}

.message.user .bubble {
    background: var(--primary-accent);
    color: #ffffff;
    border-top-right-radius: 4px;
    font-weight: 500;
    box-shadow: var(--shadow-heavy);
}

/* Inline Audio Player Upgrade */
audio {
    margin-top: 12px;
    width: 100%;
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.chat-uploaded-img {
    max-width: 100%;
    max-height: 250px;
    border-radius: 12px;
    margin-bottom: 8px;
    display: block;
    object-fit: cover;
    box-shadow: var(--shadow-heavy);
}

/* Quick Action Prompts */
.quick-actions {
    display: flex;
    gap: 10px;
    padding: 10px 30px;
    overflow-x: auto;
    scrollbar-width: none;
    background: transparent;
}
.quick-actions::-webkit-scrollbar {
    display: none;
}

.action-pill {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
    white-space: nowrap;
    box-shadow: var(--shadow-premium);
}

.action-pill:hover {
    background: var(--primary-green-soft);
    border-color: var(--primary-green);
    color: var(--primary-green);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px var(--primary-green-glow);
}

/* Premium Camera Input & Previews */
.camera-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 1.2rem;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition-smooth);
    flex-shrink: 0;
}

.camera-btn:hover {
    background: var(--primary-green-soft);
    color: var(--primary-green);
    border-color: var(--primary-green);
    transform: scale(1.05);
}

/* Chat Input Bar - Premium Pill Shape */
.input-area {
    padding: 20px 30px 25px 30px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
}

#chatInput {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: 30px;
    padding: 14px 22px;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-smooth);
}

#chatInput:focus {
    border-color: var(--primary-green);
    background: #ffffff;
    box-shadow: 0 0 0 4px var(--primary-green-glow);
}

.send-btn {
    background: var(--primary-green);
    border: none;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    color: #ffffff;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--primary-green-glow);
}

.send-btn:hover {
    background: var(--primary-accent);
    transform: scale(1.08) rotate(-10deg);
    box-shadow: var(--shadow-heavy);
}

/* Floating Image Attachment Preview */
#cameraPreviewContainer {
    padding: 10px 30px;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
}

.preview-overlay {
    position: relative;
    display: inline-block;
    width: 75px;
    height: 75px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    box-shadow: var(--shadow-premium);
}

#cameraPreview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

.clear-preview-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    border: none;
    color: #ffffff;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transition: var(--transition-smooth);
    font-weight: bold;
}

.clear-preview-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.loading {
    font-style: italic;
    color: var(--text-muted);
}

.close-sidebar-btn {
    display: none;
}

/* Responsiveness overrides */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        width: 290px;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.08);
        padding-top: 50px;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }

    .close-sidebar-btn {
        display: flex;
        position: absolute;
        top: 15px;
        right: 15px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        color: var(--text-muted);
        width: 32px;
        height: 32px;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 0.8rem;
        font-weight: 700;
        transition: var(--transition-smooth);
        z-index: 20;
    }

    .close-sidebar-btn:hover {
        background: #ef4444;
        color: #ffffff;
        border-color: #ef4444;
    }

    .menu-btn {
        display: flex;
    }

    .chat-header {
        padding: 10px 15px;
    }

    .main-title {
        font-size: 1.1rem;
    }
    
    .subtitle {
        display: none;
    }

    .lang-toggle {
        padding: 2px;
    }

    .lang-pill {
        padding: 4px 10px;
        font-size: 0.7rem;
    }

    .chat-box {
        padding: 20px 12px;
        gap: 20px;
    }

    .bubble {
        max-width: 90%;
        padding: 12px 15px;
        font-size: 0.88rem;
    }

    .input-area {
        padding: 10px 12px 18px 12px;
        gap: 8px;
    }

    #chatInput {
        padding: 10px 16px;
        font-size: 0.88rem;
    }

    .camera-btn, .send-btn {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }

    #cameraPreviewContainer {
        padding: 8px 12px;
    }

    .quick-actions {
        padding: 4px 12px;
        gap: 6px;
    }
    
    .action-pill {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
}


.hidden {
    display: none !important;
}

.hidden-file-input {
    display: none !important;
}