﻿:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f6ff;
    --text-primary: #2d2d2d;
    --text-secondary: #6b6b6b;
    --border-color: #e8e0f5;
    --accent-color: #8b5cf6;
    --accent-hover: #7c3aed;
    --error-color: #ef4444;
    --success-color: #10b981;
    --shadow: 0 1px 3px rgba(139, 92, 246, 0.1);
    --shadow-hover: 0 4px 12px rgba(139, 92, 246, 0.15);
    --shadow-card: 0 2px 8px rgba(139, 92, 246, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --gradient-primary: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    --accent-color: #8b5cf6;
    --accent-hover: #7c3aed;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 12px rgba(139, 92, 246, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans Kannada', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    padding: 0.75rem;
    font-size: 15px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

header {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: white;
    padding: 0.875rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.header-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
    filter: brightness(0) invert(1);
    transition: transform 0.2s ease;
}

.header-logo:hover {
    transform: scale(1.05);
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* Navigation Menu */
.main-navigation {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    margin-bottom: 0;
    position: relative;
    overflow: hidden;
}

.nav-menu {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin; /* Firefox - show thin scrollbar */
    scrollbar-color: var(--accent-color) var(--bg-secondary); /* Firefox scrollbar colors */
    -ms-overflow-style: -ms-autohiding-scrollbar; /* IE and Edge */
    white-space: nowrap; /* Prevent wrapping */
    max-width: 100%; /* Ensure it doesn't overflow container */
}

.nav-menu::-webkit-scrollbar {
    height: 8px; /* Show horizontal scrollbar in Chrome, Safari, Opera */
}

.nav-menu::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.nav-menu::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 4px;
}

.nav-menu::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

.nav-item {
    flex: 0 0 auto;
    min-width: 120px;
}

.nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0.625rem 0.875rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    background-color: var(--bg-primary);
    white-space: nowrap;
    min-height: 64px;
}

.nav-link:hover {
    background-color: var(--bg-secondary);
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.nav-item.active .nav-link {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
    background-color: var(--bg-secondary);
    font-weight: 600;
}

.nav-icon {
    font-size: 1.5rem;
    line-height: 1;
    margin-bottom: 2px;
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    display: inline-block;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'liga';
}

.nav-text {
    font-size: 0.75rem;
    text-align: center;
    line-height: 1.2;
}

/* Desktop Navigation - Horizontal with text (scrollable) */
@media (min-width: 769px) {
    .nav-link {
        flex-direction: row;
        gap: 6px;
        padding: 0.75rem 1.25rem;
        min-height: auto;
    }
    
    .nav-icon {
        font-size: 1.2rem;
        margin-bottom: 0;
    }
    
    .nav-text {
        font-size: 0.95rem;
    }
    
    .nav-item {
        flex: 0 0 auto; /* Don't expand, allow scrolling */
        min-width: 140px;
    }
    
    .nav-menu {
        padding: 0;
    }
}

/* Mobile Navigation - Horizontal scrollable icon buttons */
@media (max-width: 768px) {
    .nav-menu {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .nav-item {
        min-width: 80px;
        flex-shrink: 0;
    }
    
    .nav-link {
        padding: 0.75rem 0.5rem;
        border-radius: 12px;
        border-bottom: none;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        min-height: 85px;
        background: var(--bg-secondary);
    }
    
    .nav-item.active .nav-link {
        background: var(--accent-color);
        color: white;
        box-shadow: 0 4px 8px rgba(139, 92, 246, 0.3);
        transform: translateY(-2px);
    }
    
    .nav-link:hover,
    .nav-link:active {
        background: var(--bg-secondary);
        transform: scale(1.05);
    }
    
    .nav-item.active .nav-link:hover,
    .nav-item.active .nav-link:active {
        background: var(--accent-hover);
        color: white;
    }
    
    .nav-icon {
        font-size: 1.8rem;
    }
    
    .nav-text {
        font-size: 0.7rem;
        font-weight: 500;
    }
}

.theme-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.theme-toggle:active {
    transform: scale(0.92);
}

.theme-icon {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    display: inline-block;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'liga';
}

.form-section {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.form-section:last-child {
    border-bottom: none;
}

.form-section h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.form-group {
    margin-bottom: 1.125rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
    letter-spacing: -0.01em;
}

.required {
    color: var(--error-color);
    margin-left: 2px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-family: inherit;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s ease;
    line-height: 1.5;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.form-group small {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

.form-actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    background-color: var(--bg-secondary);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.btn {
    flex: 0 1 auto;
    min-width: 120px;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    box-shadow: var(--shadow-hover);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-secondary);
    border-color: var(--accent-color);
}

.btn-secondary:active {
    transform: scale(0.98);
}

.btn-icon {
    font-size: 1.1rem;
    line-height: 1;
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    display: inline-block;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'liga';
}

.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    body {
        padding: 0;
        margin: 0;
    }
    
    .container {
        border-radius: 0;
        max-width: 100%;
        box-shadow: none;
    }

    header {
        padding: 1rem;
        flex-direction: row;
        gap: 0.5rem;
        align-items: center;
        justify-content: space-between;
    }

    header h1 {
        font-size: 1.1rem;
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    header .theme-toggle {
        flex-shrink: 0;
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .form-section {
        padding: 1rem;
    }

    .form-section h2 {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .form-actions {
        flex-direction: column;
        padding: 0.875rem 1rem;
        gap: 0.625rem;
    }

    .btn {
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
    
    .alert {
        margin: 0.75rem 1rem;
        padding: 0.875rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    header {
        padding: 0.75rem;
    }
    
    header h1 {
        font-size: 1rem;
    }
    
    .form-section {
        padding: 0.75rem;
    }
    
    .form-section h2 {
        font-size: 0.95rem;
        padding-bottom: 0.375rem;
    }

    .form-group {
        margin-bottom: 0.875rem;
    }
    
    .form-group label {
        font-size: 0.875rem;
        margin-bottom: 0.375rem;
    }
}

/* Input validation styles */
.form-group input:invalid:not(:placeholder-shown),
.form-group textarea:invalid:not(:placeholder-shown) {
    border-color: var(--error-color);
}

.form-group input:valid:not(:placeholder-shown),
.form-group textarea:valid:not(:placeholder-shown) {
    border-color: var(--success-color);
}

/* Multiple Respondents/Recipients Styles */
.respondent-item,
.recipient-item {
    margin-bottom: 0.75rem;
}

.respondent-input-group,
.recipient-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.respondent-input,
.recipient-input {
    flex: 1;
    min-width: 200px;
}

.fbo-type-select {
    flex: 0 0 160px;
    min-width: 140px;
    padding: 0.625rem 0.875rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-family: inherit;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.fbo-type-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.recipient-address {
    flex: 1;
    min-width: 100%;
    margin-top: 0.5rem;
}

.btn-remove-respondent {
    padding: 0.5rem 0.875rem;
    background-color: var(--error-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-weight: 500;
}

.btn-remove-respondent:hover {
    background-color: #c0392b;
    box-shadow: var(--shadow);
}

.btn-remove-respondent:active {
    transform: scale(0.98);
}

.btn-add-respondent {
    padding: 0.625rem 1.25rem;
    background-color: var(--success-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.btn-add-respondent:hover {
    background-color: #229954;
    box-shadow: var(--shadow-hover);
}

.btn-add-respondent:active {
    transform: scale(0.98);
}

@media (max-width: 768px) {
    .respondent-input-group {
        flex-direction: column;
    }
    
    .btn-remove-respondent {
        width: 100%;
    }
}

/* Alert messages */
.alert {
    padding: 0.875rem 1rem;
    margin: 0.875rem 1.5rem;
    border-radius: var(--radius-md);
    border-left: 3px solid;
    animation: slideIn 0.3s ease;
    font-size: 0.9rem;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-error {
    background-color: rgba(231, 76, 60, 0.1);
    border-left-color: var(--error-color);
    color: var(--error-color);
}

.alert-success {
    background-color: rgba(39, 174, 96, 0.1);
    border-left-color: var(--success-color);
    color: var(--success-color);
}

.alert ul {
    margin: 0.5rem 0 0 1.5rem;
    padding: 0;
}

.alert li {
    margin: 0.25rem 0;
}

/* Subject dropdown with add button */
.subject-select {
    width: 100%;
    padding-right: 42px !important;
}

.btn-add-subject {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: calc(100% - 4px);
    padding: 0;
    min-width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--accent-color);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.btn-add-subject:hover {
    background: var(--accent-hover);
}

.btn-add-subject:active {
    transform: translateY(-50%) scale(0.95);
}

.btn-add-subject span {
    font-size: 1.2rem;
    line-height: 1;
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    display: inline-block;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'liga';
}
