/*
 * base.css - Application Base Styles
 *
 * Provides global reset, layout, header, menu, theme toggle, content, footer, and utility classes for the entire app.
 * Used by all pages (forms, landing, login, errors, etc) for consistent structure and navigation.
 *
 * Extension points: Add new global utility classes or layout rules in appropriate sections; override in page-specific CSS as needed.
 * Best practices: Use section comments for clarity; keep selectors modular and DRY; prefer variables for colors if expanding.
 */

/* Base styles shared across all pages */
/* Reset, layout, header, menu, theme toggle, content, footer, and utility classes */

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: 'Arial', sans-serif;
    background-color: #222;
    color: #eee;
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
}

body.light-mode {
    background-color: #f5f5f5;
    color: #333;
}

/* Header styles */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: #353535;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

body.light-mode .main-header {
    background-color: #f5f5f5;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Header layout */
.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 12px;
}

.header-logo {
    background: none !important;
    box-shadow: none !important;
    border-radius: 50%;
    object-fit: cover;
    width: 36px;
    height: 34px;
}

.header-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: inherit;
    letter-spacing: 0.5px;
}

/* UPDATED: Menu toggle with fixed gray box - match language selector exactly */
.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: #222;
    border: 2px solid #444;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    flex-shrink: 0;
}

body.light-mode .menu-toggle {
    background: #fff;
    border: 2px solid #ddd;
}

/* UPDATED: Menu toggle button with no hover animations */
.menu-toggle button {
    background: none;
    border: none;
    color: #4CAF50;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: none; /* REMOVED transition */
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.light-mode .menu-toggle button {
    color: #4CAF50;
}

/* UPDATED: No hover effects for menu toggle */
.menu-toggle button:hover {
    background-color: transparent; /* No hover effect */
}

body.light-mode .menu-toggle button:hover {
    background-color: transparent; /* No hover effect */
}

/* Modern square language toggle - UPDATED to match menu toggle exactly */
.language-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: #222; /* Black body like menu toggle */
    border: 2px solid #444; /* Gray border like menu toggle */
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    flex-shrink: 0;
}
body.light-mode .language-selector {
    background: #fff; /* White body in light mode like menu toggle */
    border: 2px solid #ddd; /* Light gray border in light mode like menu toggle */
}

/* UPDATED: Language button with no hover animations */
.lang-btn {
    width: 100%;
    height: 100%;
    background: none;
    border: none;
    color: #4CAF50;
    font-weight: 700;
    font-size: 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: none; /* REMOVED transition */
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 1px;
}

body.light-mode .lang-btn {
    color: #4CAF50;
}

/* UPDATED: Language button - remove active state background to show black body */
.lang-btn.en-active, .lang-btn.es-active {
    background: transparent; /* Remove gray background to show black body underneath */
    color: #4CAF50;
}
body.light-mode .lang-btn.en-active, body.light-mode .lang-btn.es-active {
    background: transparent;
    color: #4CAF50;
}
.lang-btn:focus {
    outline: 2px solid #4CAF50;
}

#themeToggle {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    position: relative;
}

#themeToggle:hover {
    background: rgba(255,255,255,0.08);
}

body.light-mode #themeToggle:hover {
    background: rgba(0,0,0,0.08);
}

#themeToggle i {
    transition: transform 0.3s ease;
}

#themeToggle:hover i {
    transform: scale(1.1);
}

/* Theme toggle icons - more specific selectors */
body.light-mode #themeToggle .fa-moon {
    display: block;
    color: #4CAF50 !important;
}

body.light-mode #themeToggle .fa-sun {
    display: none;
}

body:not(.light-mode) #themeToggle .fa-moon {
    display: none;
}

body:not(.light-mode) #themeToggle .fa-sun {
    display: block;
    color: #4CAF50 !important;
}

/* Content container adjustment for fixed header */
.content-container {
    width: 95%;
    max-width: 1000px;
    margin: 80px auto 20px;
    padding: 20px;
}

/* Side Menu */
.side-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    max-height: 100vh;
    background-color: #333;
    z-index: 2000;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.3);
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.light-mode .side-menu {
    background-color: #fff;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}

.side-menu.open {
    left: 0;
}

/* Center menu header title */
.menu-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-bottom: 1px solid #444;
    position: relative;
}

.menu-logo {
    flex: 0 0 auto;
    margin-right: 10px;
    background: none !important;
    box-shadow: none !important;
    border-radius: 50%;
    object-fit: cover;
    width: 36px;
    height: 36px;
    display: block;
}

.menu-header-title {
    flex: 1 1 auto;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 500;
    margin: 0 10px;
    white-space: normal;
}

#closeMenu {
    flex: 0 0 auto;
    margin-left: 10px;
    background: transparent;
    border: none;
    color: #eee;
    font-size: 1.2rem;
    cursor: pointer;
}

body.light-mode .menu-header {
    border-bottom: 1px solid #eee;
}

body.light-mode #closeMenu {
    color: #333;
}

.menu-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 0;
    min-height: 0;
}

.menu-nav ul {
    list-style: none;
}

/* Align Home option with other menu items */
.menu-nav a.menu-home {
    padding-left: 20px;
    display: flex;
    align-items: center;
}

.menu-nav a.menu-home i {
    margin-right: 10px;
    color: #4CAF50;
}

.menu-nav li {
    margin-bottom: 5px;
}

.menu-nav a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    text-decoration: none;
    color: #eee;
    transition: background-color 0.3s;
    position: relative;
}

.menu-nav a:hover {
    background-color: #444;
}

body.light-mode .menu-nav a {
    color: #333;
}

body.light-mode .menu-nav a:hover {
    background-color: #f5f5f5;
}

.menu-nav i {
    margin-right: 10px;
    color: #4CAF50;
    width: 24px;
    text-align: center;
}

.menu-label {
    flex: 1;
    text-align: left;
    padding-left: 0;
}

.dropdown-toggle .fa-chevron-down {
    margin-left: auto;
    width: 24px;
    text-align: center;
    font-size: 0.8em;
    transition: transform 0.3s;
}

.menu-home-text {
    margin-left: 0;
    padding-left: 0;
    display: inline-block;
}

.menu-reports-text {
    position: relative;
    left: 0;
    padding-left: 0;
    display: inline-block;
}

.reports-toggle {
    margin-left: auto;
}

.reports-icon {
    margin-right: 10px;
    width: 24px;
    text-align: center;
}

.menu-footer {
    padding: 20px;
    border-top: 1px solid #444;
    text-align: center;
    flex-shrink: 0;
}

body.light-mode .menu-footer {
    border-top: 1px solid #eee;
}

.menu-footer-user {
    position: relative;
    width: 100%;
    min-height: 36px;
}

body.light-mode .menu-footer-user {
    color: #333;
}

.user-name {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-weight: 500;
    font-size: 1rem;
    margin: 0;
    white-space: nowrap;
}

.settings-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.settings-btn:hover {
    background: rgba(255,255,255,0.08);
}

body.light-mode .settings-btn:hover {
    background: rgba(0,0,0,0.08);
}

.footer-user-img {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: #bbb;
}

/* Menu Dropdown Styles */
.menu-dropdown {
    position: relative;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
}

.dropdown-toggle i {
    width: 24px;
    text-align: center;
    color: #4CAF50 !important; /* Ensure main dropdown icons stay green */
}

.dropdown-toggle .fa-chevron-down {
    width: 24px;
    text-align: center;
    margin-left: 8px;
    color: #4CAF50 !important; /* Ensure chevron stays green */
}

/* Ensure dropdown toggle icons stay green in all states */
.menu-dropdown .dropdown-toggle i,
.menu-dropdown.active .dropdown-toggle i {
    color: #4CAF50 !important;
}

body.light-mode .dropdown-toggle {
    color: #333;
}

.dropdown-toggle:hover {
    background-color: #444;
}

body.light-mode .dropdown-toggle:hover {
    background-color: #f5f5f5;
}

.dropdown-toggle i.fa-chevron-down {
    margin-left: 8px;
    font-size: 0.8em;
    transition: transform 0.3s;
    color: #4CAF50 !important;
}

.menu-dropdown.active .dropdown-toggle i.fa-chevron-down {
    transform: rotate(180deg);
}

.dropdown-menu {
    display: none;
    background-color: #2a2a2a;
    padding: 5px 0;
}

body.light-mode .dropdown-menu {
    background-color: #f0f0f0;
}

.menu-dropdown.active .dropdown-menu {
    display: block;
}

.dropdown-menu li a {
    display: flex;
    justify-content: center;
    align-items: center;
    padding-left: 0;
    font-size: 0.95em;
    text-align: center;
    width: 100%;
}

.dropdown-menu li a i {
    color: #4CAF50 !important;
    margin-right: 8px;
}

/* Also ensure light mode icons are green */
body.light-mode .dropdown-menu li a i {
    color: #4CAF50 !important;
}

/* Target all FontAwesome icons in dropdown menus specifically */
.dropdown-menu li a i.fas,
.dropdown-menu li a i.fa,
.menu-nav .dropdown-menu li a i {
    color: #4CAF50 !important;
}

body.light-mode .dropdown-menu li a i.fas,
body.light-mode .dropdown-menu li a i.fa,
body.light-mode .menu-nav .dropdown-menu li a i {
    color: #4CAF50 !important;
}

.dropdown-menu li a:hover {
    background-color: #444;
}

body.light-mode .dropdown-menu li a:hover {
    background-color: #e0e0e0;
}

/* Under Construction Badge in Menu */
.dropdown-menu li a.under-construction {
    position: relative;
    opacity: 0.85;
}

.dropdown-menu li a.under-construction .construction-badge {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #ff9800;
    color: white;
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
}

.dropdown-menu li a.under-construction .construction-badge i {
    font-size: 0.7rem;
    margin: 0;
}

.dropdown-menu li a.under-construction:hover {
    opacity: 1;
}

body.light-mode .dropdown-menu li a.under-construction .construction-badge {
    background: #ff9800;
    color: white;
}

.dropdown-menu .menu-label {
    flex: unset;
    text-align: center;
    padding-left: 0;
}

/* Form elements */
input, select, textarea, button {
    font-family: inherit;
    font-size: 1rem;
}

button, .button {
    display: inline-block;
    padding: 10px 20px;
    background-color: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.3s;
}

button:hover, .button:hover {
    background-color: #45a049;
}

/* Utility classes */
.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 3rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 3rem; }

/* Footer */
footer {
    background-color: #333;
    border-top: 1px solid #444;
    padding: 20px 0;
    font-size: 0.9rem;
    color: #999;
    margin-top: 0;
}

body.light-mode footer {
    background-color: #f9f9f9;
    border-top: 1px solid #eee;
    color: #666;
}

.footer-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

/* Overlay when menu is open */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    display: none;
}

.menu-overlay.active {
    display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .content-container {
        width: 100%;
        padding: 15px;
    }
    
    .main-header {
        padding: 0 15px;
    }
    
    /* Make language selector and menu toggle consistent shapes on mobile */
    .language-selector {
        width: 48px !important;
        height: 48px !important;
        border-radius: 10px !important;
    }
    
    .menu-toggle {
        width: 48px !important;
        height: 48px !important;
        border-radius: 10px !important;
    }
    
    .lang-btn {
        font-size: 1.1rem;
        height: 100%;
    }
    
    .side-menu {
        width: 85%;
        left: -85%;
        max-width: 320px;
    }
    
    /* Reduce menu padding and spacing on mobile */
    .menu-nav {
        padding: 15px 0 !important;
    }
    
    .menu-nav a {
        padding: 10px 15px !important;
    }
    
    .menu-header {
        padding: 15px !important;
    }
    
    .menu-footer {
        padding: 15px !important;
    }
    
    .dropdown-menu {
        padding: 5px 0 !important;
    }
    
    .dropdown-menu li a {
        padding: 8px 15px !important;
        font-size: 0.9rem !important;
    }
    
    .header-title {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .main-header {
        padding: 0 5px;
        height: auto;
        min-height: 48px;
        flex-wrap: wrap;
    }
    
    .header-center {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        margin: 0 auto;
        flex: 1;
        min-width: 0;
    }
    
    .header-logo {
        width: 28px;
        height: 28px;
        flex-shrink: 0;
    }
    
    .header-title {
        font-size: 0.85rem;
        font-weight: 600;
        max-width: calc(100% - 120px);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: inline-block;
        vertical-align: middle;
        line-height: 1.1;
        text-align: center;
        margin-left: 0;
        flex-shrink: 1;
    }
    
    /* Keep consistent shapes on very small screens */
    .language-selector {
        width: 40px !important;
        height: 40px !important;
        margin-right: 2px;
        border-radius: 8px !important;
    }
    
    .menu-toggle {
        width: 40px !important;
        height: 40px !important;
        border-radius: 8px !important;
    }
    
    .lang-btn {
        font-size: 0.9rem;
    }
    
    .side-menu {
        width: 90%;
        left: -90%;
        max-width: 300px;
    }
    
    /* Further reduce menu spacing on very small screens */
    .menu-nav {
        padding: 10px 0 !important;
    }
    
    .menu-nav a {
        padding: 8px 12px !important;
        font-size: 0.9rem !important;
    }
    
    .menu-header {
        padding: 12px !important;
    }
    
    .menu-footer {
        padding: 12px !important;
    }
    
    .dropdown-menu {
        padding: 3px 0 !important;
    }
    
    .dropdown-menu li a {
        padding: 6px 12px !important;
        font-size: 0.85rem !important;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* CRITICAL: Force distribution form dropdown icons to be green - highest specificity */
.side-menu .menu-nav .menu-dropdown .dropdown-menu li a i.fas,
.side-menu .menu-nav .dropdown-menu li a i.fas {
    color: #4CAF50 !important;
}

/* Target specific distribution form icons that are showing as white */
.dropdown-menu li a i.fa-warehouse,
.dropdown-menu li a i.fa-shipping-fast,
.dropdown-menu li a i.fa-vial,
.dropdown-menu li a i.fa-route {
    color: #4CAF50 !important;
}

/* Focus states for accessibility */
.lang-btn:focus {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}

body.light-mode .lang-btn:focus {
    outline-color: #333;
}

/* Settings dropdown as upward submenu in menu footer */
.settings-dropdown-menu {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    width: 100%;
    background: #333;
    border-radius: 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.10);
    border: none;
    padding: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(30px) scaleY(0.95);
    transition: transform 0.32s cubic-bezier(0.4,0,0.2,1), opacity 0.28s cubic-bezier(0.4,0,0.2,1);
}
.settings-dropdown-menu.open {
    opacity: 1;
    pointer-events: auto;
    padding: 12px 0 8px 0;
    transform: translateY(0) scaleY(1);
}
.settings-dropdown-menu .logout-btn,
.settings-dropdown-menu .settings-option {
    background: none;
    border: none;
    color: #eee;
    text-align: left;
    padding: 10px 28px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 0;
}
.settings-dropdown-menu .logout-btn:hover,
.settings-dropdown-menu .settings-option:hover:not(:disabled) {
    background: #444;
}
.settings-dropdown-menu .settings-option:disabled {
    color: #888;
    cursor: not-allowed;
}

/* Light mode for settings dropdown submenu */
body.light-mode .settings-dropdown-menu {
    background: #fff;
    color: #222;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}
body.light-mode .settings-dropdown-menu .logout-btn,
body.light-mode .settings-dropdown-menu .settings-option {
    color: #222;
}
body.light-mode .settings-dropdown-menu .logout-btn:hover,
body.light-mode .settings-dropdown-menu .settings-option:hover:not(:disabled) {
    background: #f5f5f5;
}
body.light-mode .settings-dropdown-menu .settings-option:disabled {
    color: #bbb;
}

/* Always make the settings cog green */
.settings-btn,
.settings-btn i.fa-cog {
    color: #4CAF50 !important;
}

/* Always make the theme toggle icons green */
#themeToggle i.fa-moon,
#themeToggle i.fa-sun {
    color: #4CAF50 !important;
}

.settings-dropdown-menu .logout-btn i.fa-sign-out-alt {
    color: #4CAF50 !important;
}
body.light-mode .settings-dropdown-menu .logout-btn i.fa-sign-out-alt {
    color: #4CAF50 !important;
}