/* BAUSOFT24 - Universal Theme System CSS */
/* Import modern font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ===== MODERN THEME (DEFAULT) ===== */
:root {
    /* Modern Colors */
    --bg-primary: #F8F9FA;
    --bg-secondary: #FFFFFF;
    --text-primary: #1A1A1A;
    --text-secondary: #6B7280;
    --accent-blue: #3B82F6;
    --accent-green: #10B981;
    --accent-orange: #F59E0B;
    --accent-purple: #8B5CF6;
    --accent-red: #EF4444;
    --border: #E5E7EB;
    --shadow: rgba(0, 0, 0, 0.1);

    /* Retro Colors (for theme toggle) */
    --neon-cyan: #00FFFF;
    --neon-magenta: #FF00FF;
    --neon-yellow: #FFFF00;
    --neon-green: #00FF00;
    --neon-orange: #FF6600;
    --neon-red: #FF0066;
    --dark-bg: #0A0A0A;
}

/* Apply modern theme as default */
body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ===== THEME TOGGLE BUTTON ===== */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 80px;
    height: 80px;
    border-radius: 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    box-shadow: 0 4px 20px var(--shadow);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: all 0.3s ease;
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
}

.theme-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 30px var(--shadow);
}

.theme-toggle-text {
    font-size: 10px;
    margin-top: 4px;
    text-align: center;
    line-height: 1.2;
}

/* ===== BACK BUTTON ===== */
.back-button {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    box-shadow: 0 4px 20px var(--shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: all 0.3s ease;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
}

.back-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 30px var(--shadow);
}

body.retro-theme .back-button {
    background: transparent;
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    box-shadow: 0 0 20px var(--neon-cyan);
}

/* ===== RETRO THEME OVERRIDES ===== */
body.retro-theme {
    background: var(--dark-bg);
    color: var(--neon-cyan);
    font-family: 'Share Tech Mono', 'Courier New', monospace;
}

body.retro-theme .theme-toggle {
    background: transparent;
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    box-shadow: 0 0 20px var(--neon-cyan);
}

/* Retro scanline effect */
body.retro-theme::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15) 0px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 9999;
    animation: scanline 10s linear infinite;
}

@keyframes scanline {
    0% { transform: translateY(0); }
    100% { transform: translateY(10px); }
}

/* Retro grid background */
body.retro-theme::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(0deg, transparent 24%, rgba(255, 0, 255, .05) 25%, transparent 26%),
        linear-gradient(90deg, transparent 24%, rgba(0, 255, 255, .05) 25%, transparent 26%);
    background-size: 50px 50px;
    opacity: 0.3;
    pointer-events: none;
    z-index: 1;
    animation: gridMove 20s linear infinite;
}

@keyframes gridMove {
    0% { transform: perspective(500px) rotateX(60deg) translateY(0); }
    100% { transform: perspective(500px) rotateX(60deg) translateY(50px); }
}

/* Retro text glow */
body.retro-theme h1,
body.retro-theme h2,
body.retro-theme h3 {
    font-family: 'Orbitron', sans-serif;
    text-shadow: 0 0 10px currentColor;
}

/* Retro button styles */
body.retro-theme button {
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
    box-shadow: 0 0 10px var(--neon-cyan);
}

body.retro-theme button:hover:not(:disabled) {
    background: var(--neon-cyan);
    color: var(--dark-bg);
    box-shadow: 0 0 20px var(--neon-cyan);
}

/* Retro container z-index fix for pseudo-elements */
body.retro-theme .container {
    position: relative;
    z-index: 2;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: white;
    border-radius: 12px;
    padding: 16px 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10001;
    opacity: 0;
    transition: all 0.3s ease;
    min-width: 300px;
    max-width: 500px;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-success {
    border-left: 4px solid var(--accent-green);
}

.toast-error {
    border-left: 4px solid var(--accent-red);
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-message {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Retro theme toast */
body.retro-theme .toast {
    background: var(--dark-bg);
    border: 2px solid var(--neon-cyan);
    box-shadow: 0 0 30px var(--neon-cyan);
}

body.retro-theme .toast-success {
    border-color: var(--neon-green);
    box-shadow: 0 0 30px var(--neon-green);
}

body.retro-theme .toast-error {
    border-color: var(--neon-red);
    box-shadow: 0 0 30px var(--neon-red);
}

body.retro-theme .toast-message {
    color: var(--neon-cyan);
}

/* ===== CONFIRMATION MODAL ===== */
.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.confirm-modal.show {
    opacity: 1;
    pointer-events: all;
}

.confirm-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.confirm-dialog {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.confirm-modal.show .confirm-dialog {
    transform: scale(1);
}

.confirm-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.confirm-message {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.confirm-btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.confirm-cancel {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--border);
}

.confirm-cancel:hover {
    background: var(--bg-secondary);
}

.confirm-yes {
    background: var(--accent-red);
    color: white;
}

.confirm-yes:hover {
    background: #DC2626;
}

/* Retro theme modal */
body.retro-theme .confirm-dialog {
    background: var(--dark-bg);
    border: 2px solid var(--neon-magenta);
    box-shadow: 0 0 40px var(--neon-magenta);
}

body.retro-theme .confirm-title {
    color: var(--neon-magenta);
    text-shadow: 0 0 10px var(--neon-magenta);
}

body.retro-theme .confirm-message {
    color: var(--neon-cyan);
}

body.retro-theme .confirm-cancel {
    background: transparent;
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
}

body.retro-theme .confirm-cancel:hover {
    background: var(--neon-cyan);
    color: var(--dark-bg);
}

body.retro-theme .confirm-yes {
    background: transparent;
    border-color: var(--neon-red);
    color: var(--neon-red);
    box-shadow: 0 0 10px var(--neon-red);
}

body.retro-theme .confirm-yes:hover {
    background: var(--neon-red);
    color: var(--dark-bg);
}

/* ===== BUTTON LOADING STATES ===== */
button.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== FORM VALIDATION ===== */
input.error,
textarea.error,
select.error {
    border-color: var(--accent-red) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

body.retro-theme input.error,
body.retro-theme textarea.error,
body.retro-theme select.error {
    border-color: var(--neon-red) !important;
    box-shadow: 0 0 10px var(--neon-red);
}

.field-error {
    color: var(--accent-red);
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.field-error::before {
    content: '⚠️';
}

body.retro-theme .field-error {
    color: var(--neon-red);
}

/* Visual feedback for valid fields */
input:valid:not(:placeholder-shown),
textarea:valid:not(:placeholder-shown),
select:valid {
    border-color: var(--accent-green);
}

body.retro-theme input:valid:not(:placeholder-shown),
body.retro-theme textarea:valid:not(:placeholder-shown),
body.retro-theme select:valid {
    border-color: var(--neon-green);
}

/* ===== MOBILE RESPONSIVE (Construction Worker Optimized) ===== */
@media (max-width: 768px) {
    /* Container adjustments */
    .container {
        padding: 16px 12px !important;
        max-width: 100% !important;
    }

    /* Touch-friendly buttons - minimum 60px height */
    button,
    .button,
    a.button,
    input[type="submit"],
    input[type="button"] {
        min-height: 60px !important;
        font-size: 18px !important;
        padding: 16px 20px !important;
        width: 100%;
        margin-bottom: 12px;
    }

    /* Theme toggle - move to avoid thumb zone conflicts */
    .theme-toggle {
        top: 12px;
        right: 12px;
        width: 56px;
        height: 56px;
        font-size: 24px;
    }

    .theme-toggle-text {
        font-size: 8px;
    }

    /* Back button */
    .back-button {
        top: 12px;
        left: 12px;
        width: 56px;
        height: 56px;
        font-size: 20px;
    }

    /* Prevent input zoom on iOS - minimum 16px font size */
    input,
    textarea,
    select {
        font-size: 16px !important;
        min-height: 56px !important;
        padding: 16px !important;
    }

    /* Stack elements vertically */
    .grid,
    .row,
    [style*="display: flex"],
    [style*="grid-template-columns"] {
        display: block !important;
        grid-template-columns: 1fr !important;
    }

    /* Stats grid - 2 columns on mobile */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }

    /* Hide less important elements on mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Forms - full width */
    form input,
    form textarea,
    form select {
        width: 100% !important;
    }

    /* Modal adjustments */
    .confirm-dialog {
        width: 95% !important;
        padding: 24px 16px !important;
    }

    .confirm-buttons {
        flex-direction: column-reverse !important;
        gap: 8px !important;
    }

    .confirm-btn {
        width: 100% !important;
        min-height: 60px !important;
    }

    /* Toast notifications */
    .toast {
        width: 90% !important;
        min-width: unset !important;
    }

    /* Tables - horizontal scroll or card layout */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Card layout for lists on mobile */
    .table-card-mobile {
        display: block !important;
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 12px;
        background: var(--bg-secondary);
    }

    /* Typography adjustments */
    h1 {
        font-size: 28px !important;
    }

    h2 {
        font-size: 22px !important;
    }

    h3 {
        font-size: 18px !important;
    }

    /* Action buttons in cards */
    .action-buttons {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        margin-top: 12px !important;
    }

    .action-buttons button {
        width: 100% !important;
    }

    /* Search and filters */
    .search-bar,
    .filter-bar {
        width: 100% !important;
        margin-bottom: 16px !important;
    }

    /* Mega buttons on dashboard */
    .mega-button {
        min-height: 100px !important;
        font-size: 18px !important;
    }

    .mega-button-icon {
        font-size: 40px !important;
    }

    .mega-button-title {
        font-size: 16px !important;
    }

    .mega-button-desc {
        font-size: 13px !important;
    }

    /* Bottom navigation for thumb-zone optimization */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        display: flex;
        justify-content: space-around;
        padding: 8px 0;
        z-index: 1000;
    }

    body.retro-theme .mobile-bottom-nav {
        background: var(--dark-bg);
        border-top: 2px solid var(--neon-cyan);
        box-shadow: 0 -4px 20px var(--neon-cyan);
    }

    .mobile-bottom-nav button {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--text-secondary);
        font-size: 12px;
        padding: 8px;
        min-height: 60px;
        margin: 0;
    }

    .mobile-bottom-nav button.active {
        color: var(--accent-blue);
    }

    body.retro-theme .mobile-bottom-nav button {
        color: var(--neon-cyan);
    }

    body.retro-theme .mobile-bottom-nav button.active {
        color: var(--neon-magenta);
    }

    .mobile-bottom-nav button .icon {
        font-size: 24px;
        margin-bottom: 4px;
    }

    /* Add bottom padding to prevent content hiding under nav */
    body.has-bottom-nav .container {
        padding-bottom: 80px !important;
    }

    /* Voice/Photo invoice specific */
    .record-button,
    .photo-button {
        width: 100% !important;
        min-height: 80px !important;
        font-size: 20px !important;
    }

    /* Form groups - better spacing */
    .form-group {
        margin-bottom: 20px !important;
    }

    label {
        font-size: 16px !important;
        margin-bottom: 8px !important;
    }

    /* Spacing adjustments for thumb-zone */
    .primary-actions {
        margin-bottom: 24px !important;
    }

    /* More options toggle */
    .toggle-more {
        width: 100% !important;
        min-height: 60px !important;
        font-size: 18px !important;
    }

    /* Stats cards */
    .stat-card {
        padding: 16px !important;
        min-height: 80px !important;
    }

    /* Client/Invoice/Project cards on mobile */
    .item-card {
        padding: 16px !important;
        margin-bottom: 16px !important;
    }

    .item-card h3 {
        font-size: 18px !important;
        margin-bottom: 8px !important;
    }

    .item-card p {
        font-size: 14px !important;
        line-height: 1.6 !important;
    }

    /* Reduce motion for better mobile performance */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }

    /* Landscape mode adjustments */
    @media (orientation: landscape) {
        .mega-button {
            min-height: 80px !important;
        }

        .mobile-bottom-nav {
            padding: 4px 0;
        }

        .mobile-bottom-nav button {
            min-height: 50px;
        }
    }
}

/* Tablet optimizations (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    button,
    .button {
        min-height: 50px;
        font-size: 16px;
    }

    input,
    textarea,
    select {
        min-height: 48px;
        font-size: 16px;
    }

    .container {
        padding: 24px;
    }
}
