/* Modern Litemarshal Design */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-elevated: #334155;
    --text: #f1f5f9;
    --text-muted: #a8b8d0;
    --border: #475569;
    --shadow: rgba(0, 0, 0, 0.3);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Light mode theme */
[data-theme="light"] {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #2563eb;  /* Changed: use primary for better contrast (5.79:1) */
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --success: #059669;
    --warning: #d97706;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-elevated: #e2e8f0;  /* Changed: better visual distinction from white */
    --text: #0f172a;
    --text-muted: #475569;  /* Changed: improved contrast 7.04:1 (was 4.04:1) */
    --border: #94a3b8;  /* Changed: improved contrast 3.18:1 (was 1.77:1) */
    --shadow: rgba(0, 0, 0, 0.1);
}

/* Light mode specific overrides for status colors */
[data-theme="light"] .lite-error {
    color: #991b1b;  /* Dark red - 8.89:1 contrast (was 2.21:1) */
}

[data-theme="light"] .lite-warning {
    color: #92400e;  /* Dark amber - 7.12:1 contrast (was 1.43:1) */
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* Login Page */
.lite-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg) 100%);
}

/* Light mode background gradient */
[data-theme="light"] .lite-body {
    background: linear-gradient(135deg, #e0e7ff 0%, #f8fafc 100%);
}

.lite-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.lite-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 20px 40px var(--shadow);
    border: 1px solid var(--border);
    width: 100%;
    position: relative;
}

/* Login card specifically has max-width */
.lite-body .lite-card {
    max-width: 520px;
    width: 100%;
}

/* Dashboard cards should fill their grid areas */
body:not(.lite-body) .lite-card {
    max-width: 100%;
}

.lite-title {
    margin: 0 0 8px;
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.lite-subtitle {
    margin: 0 0 32px;
    color: var(--text-muted);
    font-size: 16px;
}

.lite-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.lite-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lite-input,
.lite-button,
.lite-secondary,
.lite-danger,
select.lite-input {
    font-size: 16px;
    border-radius: 10px;
    border: 2px solid var(--border);
    padding: 14px 16px;
    font-family: inherit;
    background: var(--bg-elevated);
    color: var(--text);
    transition: all 0.3s ease;
}

.lite-input:focus,
select.lite-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.lite-button {
    border: none;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    cursor: pointer;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lite-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
}

.lite-button:active {
    transform: translateY(0);
}

.lite-footer {
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

.lite-error,
.lite-warning {
    padding: 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid;
    font-size: 14px;
    animation: slideIn 0.3s ease;
}

.lite-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: #fca5a5;
}

.lite-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--warning);
    color: #fbbf24;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Info boxes for login page */
.info-box-primary,
.info-box-danger {
    border-radius: 10px;
    padding: 14px;
    border: 2px solid;
}

.info-box-primary {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--primary);
}

.info-box-danger {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
}

/* Light mode info boxes */
[data-theme="light"] .info-box-primary {
    background: rgba(37, 99, 235, 0.1);
}

[data-theme="light"] .info-box-danger {
    background: rgba(220, 38, 38, 0.15);
}

/* Danger text color adapts to theme */
.danger-text {
    color: #fca5a5;
}

[data-theme="light"] .danger-text {
    color: #991b1b;  /* Dark red for light mode - 8.89:1 contrast */
}

/* Dashboard */
.lite-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
}

.lite-header h1 {
    margin: 0;
    font-size: 28px;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.lite-tagline {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 14px;
}

.lite-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.lite-handle {
    font-weight: 600;
    color: var(--primary-light);
    padding: 8px 16px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 20px;
}

.lite-secondary {
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
    border: 2px solid var(--border);
}

.lite-secondary:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.lite-link {
    color: var(--primary-light);
    text-decoration: none;
    padding: 10px 16px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.lite-link:hover {
    background: rgba(59, 130, 246, 0.1);
}

.lite-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.lite-summary-item {
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-elevated) 100%);
    transition: all 0.3s ease;
}

.lite-summary-item:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.2);
}

.lite-summary-value {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-light);
    margin-bottom: 4px;
}

.lite-summary-label {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lite-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.lite-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lite-field span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lite-field.full {
    grid-column: 1 / -1;
}

.lite-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.lite-results-header h2 {
    margin: 0;
    font-size: 20px;
}

.lite-results-actions {
    display: flex;
    gap: 8px;
}

.lite-danger {
    border: none;
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-dark) 100%);
    color: white;
    cursor: pointer;
}

.lite-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.3);
}

.lite-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.lite-small {
    padding: 6px 12px;
    font-size: 13px;
}

.lite-table-wrapper {
    overflow-x: auto;
    margin-top: 16px;
    border-radius: 12px;
    border: 2px solid var(--border);
}

.lite-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

.lite-table th {
    background: var(--bg-elevated);
    text-align: left;
    padding: 16px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

.lite-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.lite-table tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

.lite-chip {
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary-light);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.lite-text {
    max-width: 100%;
    white-space: pre-wrap;
    line-height: 1.5;
    word-wrap: break-word;
}

.lite-pill {
    display: inline-block;
    margin-right: 8px;
    margin-bottom: 4px;
    padding: 4px 10px;
    border-radius: 16px;
    background: var(--bg-elevated);
    font-size: 12px;
    border: 1px solid var(--border);
}

.lite-meta {
    color: var(--text-muted);
    font-size: 14px;
    font-style: italic;
}

/* Focus indicators for accessibility */
*:focus {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.lite-input:focus,
.lite-button:focus,
.lite-secondary:focus,
.lite-danger:focus,
select.lite-input:focus {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 5px rgba(59, 130, 246, 0.2);
}

/* Checkbox focus indicators */
input[type="checkbox"]:focus {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 5px rgba(59, 130, 246, 0.2);
}

label:has(input[type="checkbox"]:focus) {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Link focus */
a:focus {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Checkbox labels hover effect */
label:has(input[type="checkbox"]):hover {
    border-color: var(--primary) !important;
    background: rgba(59, 130, 246, 0.1) !important;
}

label:has(input[type="checkbox"]:checked) {
    border-color: var(--primary) !important;
    background: rgba(59, 130, 246, 0.15) !important;
}

/* Theme toggle button */
.theme-toggle {
    background: var(--bg-elevated);
    border: 2px solid var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.theme-toggle:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.theme-toggle:focus {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Screen reader only class */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Mobile touch devices */
    .lite-input,
    .lite-button,
    .lite-secondary,
    .lite-danger {
        min-height: 44px;
        font-size: 16px; /* Prevent iOS zoom on focus */
    }

    .lite-small {
        min-height: 36px;
    }

    /* Larger tap targets for buttons */
    button,
    a.lite-button,
    a.app-password-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Better checkbox tap targets */
    label:has(input[type="checkbox"]) {
        min-height: 44px;
        display: flex !important;
        align-items: center;
        padding: 12px !important;
    }

    /* Remove hover effects on touch devices */
    *:hover {
        transition: none;
    }

    /* Improve scrolling */
    .lite-table-wrapper {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    main[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    aside {
        order: 2;
    }

    section.lite-card[style*="min-height"] {
        order: 1;
    }
}

@media (max-width: 768px) {
    /* Force single column on tablets and mobile */
    body[style*="padding: 24px"] {
        padding: 16px !important;
    }

    .lite-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 16px 0;
    }

    .lite-header h1 {
        font-size: 24px;
    }

    .lite-tagline {
        font-size: 13px;
    }

    .lite-header-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }

    .lite-handle {
        font-size: 13px;
        padding: 6px 12px;
    }

    /* Stack sidebar and main content */
    main[style*="grid-template-columns: 300px"] {
        grid-template-columns: 1fr !important;
    }

    aside {
        order: 2;
        width: 100%;
    }

    section.lite-card[style*="min-height"] {
        order: 1;
        min-height: auto !important;
    }

    .lite-results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .lite-results-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .lite-results-actions button {
        width: 100%;
    }

    /* Search form responsive */
    form[role="search"] > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Checkbox labels stack better on mobile */
    div:has(> label > input[type="checkbox"]) {
        gap: 10px !important;
    }

    label:has(input[type="checkbox"]) {
        padding: 10px !important;
        font-size: 13px !important;
    }

    label:has(input[type="checkbox"]) input {
        width: 16px !important;
        height: 16px !important;
    }

    label:has(input[type="checkbox"]) span {
        font-size: 13px !important;
    }

    /* Table responsive */
    .lite-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .lite-table {
        font-size: 12px;
    }

    .lite-table th,
    .lite-table td {
        padding: 10px 8px;
        font-size: 11px;
    }

    .lite-chip {
        font-size: 10px;
        padding: 4px 8px;
    }

    .lite-pill {
        font-size: 10px;
        padding: 3px 8px;
        margin-right: 4px;
    }

    .lite-card {
        padding: 16px;
    }

    .lite-title {
        font-size: 22px;
    }

    .lite-subtitle {
        font-size: 13px;
        margin-bottom: 16px;
    }
}

@media (max-width: 480px) {
    /* Mobile phones - ultra compact */
    body[style*="padding"] {
        padding: 12px !important;
    }

    .lite-body {
        padding: 12px !important;
    }

    .lite-main {
        padding: 12px !important;
    }

    .lite-card {
        padding: 16px !important;
        border-radius: 12px;
    }

    .lite-title {
        font-size: 20px;
    }

    .lite-subtitle {
        font-size: 12px;
    }

    .lite-header h1 {
        font-size: 20px;
    }

    .lite-tagline {
        font-size: 11px;
    }

    .lite-input,
    .lite-button,
    .lite-secondary,
    .lite-danger {
        font-size: 14px !important;
        padding: 12px !important;
    }

    .lite-small {
        font-size: 12px !important;
        padding: 8px 10px !important;
    }

    .lite-label {
        font-size: 11px;
    }

    .lite-field span {
        font-size: 11px !important;
    }

    .app-password-link {
        padding: 12px 20px;
        font-size: 14px;
        width: 100%;
        display: block;
        text-align: center;
    }

    /* Login page info boxes */
    div[style*="max-width: 520px"] {
        max-width: 100% !important;
    }

    div[style*="max-width: 520px"] > div {
        padding: 12px !important;
    }

    div[style*="max-width: 520px"] h2 {
        font-size: 11px !important;
    }

    div[style*="max-width: 520px"] p {
        font-size: 11px !important;
    }

    /* Rotating tip mobile */
    #rotating-tip {
        min-height: 60px !important;
        padding: 10px 0 !important;
    }

    #tip-text {
        font-size: 12px !important;
    }

    /* Results actions stack vertically on very small screens */
    .lite-results-actions {
        grid-template-columns: 1fr !important;
    }

    /* Search form - full width on mobile */
    .lite-search-section .lite-input,
    .lite-search-section input[type="text"],
    .lite-search-section input[type="number"],
    .lite-search-section input[type="date"] {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    /* Search grid - stack on mobile */
    .lite-search-grid,
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Results section - full width container */
    .lite-results-section {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto;
    }

    /* Table container with horizontal scroll */
    .lite-table-container,
    .lite-table {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Table more compact on mobile but still readable */
    .lite-table {
        min-width: 100%;
        font-size: 11px;
    }

    .lite-table th,
    .lite-table td {
        padding: 8px 6px;
        font-size: 10px;
    }

    .lite-chip {
        font-size: 9px;
        padding: 3px 6px;
    }

    .lite-pill {
        font-size: 9px;
        padding: 2px 6px;
    }

    /* Sidebar sections more compact */
    aside section.lite-card {
        padding: 12px !important;
    }

    aside h2 {
        font-size: 12px !important;
        margin-bottom: 8px !important;
    }

    aside p {
        font-size: 10px !important;
    }
}

/* Loading Animation */
.loading-spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

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

.btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-text {
    transition: opacity 0.3s ease;
}

/* App password link styling */
.lite-footer {
    text-align: center;
}

.app-password-link {
    display: inline-block;
    margin-top: 16px;
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 2px solid var(--primary);
}

.app-password-link:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
