/* Mystira PWA Global Styles */

:root {
    --primary-color: #7c3aed;
    --primary-hover: #6d28d9;
    --secondary-color: #4b5563;
    --secondary-hover: #374151;
    --secondary-bg: #f3f4f6;
    --success-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --info-color: #3B82F6;
    --light-color: #F9FAFB;
    --dark-color: #111827;

    /* Light theme colors (default) */
    --bg: #f8fafc;
    --fg: #111827;
    --muted: #6b7280;
    --card: rgba(255,255,255,0.85);
    --border: rgba(17,24,39,0.08);
    --glow: rgba(52,211,153,0.35);
    --accent: #22c55e;

    /* dice appearance */
    --die-grad1: #ffffff;
    --die-grad2: #d4d4d8;
    --pip: #111827;

    /* navbar appearance */
    --navbar-bg: rgba(255, 255, 255, 0.85);
    --navbar-border: rgba(17, 24, 39, 0.08);
    --navbar-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    --nav-link-color: #111827;
}

/* Dark mode using prefers-color-scheme */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --fg: #f1f5f9;
        --muted: #94a3b8;
        --card: rgba(30, 41, 59, 0.85);
        --border: rgba(148, 163, 184, 0.1);
        --glow: rgba(134, 239, 172, 0.25);
        --accent: #34d399;

        --secondary-color: #9ca3af;
        --secondary-hover: #d1d5db;
        --secondary-bg: #374151;

        --die-grad1: #334155;
        --die-grad2: #1e293b;
        --pip: #f1f5f9;

        --light-color: #1e293b;
        --dark-color: #f1f5f9;

        /* navbar appearance */
        --navbar-bg: rgba(15, 23, 42, 0.95);
        --navbar-border: rgba(148, 163, 184, 0.15);
        --navbar-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(148, 163, 184, 0.1);
        --nav-link-color: #e2e8f0;
    }
}

/* Manual dark mode toggle (can be set via JavaScript on html element) */
html[data-theme="dark"] {
    --bg: #0f172a;
    --fg: #f1f5f9;
    --muted: #94a3b8;
    --card: rgba(30, 41, 59, 0.85);
    --border: rgba(148, 163, 184, 0.1);
    --glow: rgba(134, 239, 172, 0.25);
    --accent: #34d399;

    --secondary-color: #9ca3af;
    --secondary-hover: #d1d5db;
    --secondary-bg: #374151;

    --die-grad1: #334155;
    --die-grad2: #1e293b;
    --pip: #f1f5f9;

    --light-color: #1e293b;
    --dark-color: #f1f5f9;

    /* navbar appearance */
    --navbar-bg: rgba(15, 23, 42, 0.95);
    --navbar-border: rgba(148, 163, 184, 0.15);
    --navbar-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(148, 163, 184, 0.1);
    --nav-link-color: #e2e8f0;
}

html[data-theme="light"] {
    --bg: #f8fafc;
    --fg: #111827;
    --muted: #6b7280;
    --card: rgba(255,255,255,0.85);
    --border: rgba(17,24,39,0.08);
    --glow: rgba(52,211,153,0.35);
    --accent: #22c55e;

    --secondary-color: #4b5563;
    --secondary-hover: #374151;
    --secondary-bg: #f3f4f6;

    --die-grad1: #ffffff;
    --die-grad2: #d4d4d8;
    --pip: #111827;

    /* navbar appearance */
    --navbar-bg: rgba(255, 255, 255, 0.85);
    --navbar-border: rgba(17, 24, 39, 0.08);
    --navbar-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    --nav-link-color: #111827;
}

html, body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--fg);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Global Utility Classes */
.bg-primary-custom {
    background-color: var(--primary-color) !important;
}

.text-primary-custom {
    color: var(--primary-color) !important;
}

.btn-primary-custom {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    /* Ensure Bootstrap button CSS variables produce white text in all states */
    --bs-btn-color: #ffffff;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-active-color: #ffffff;
    --bs-btn-disabled-color: #ffffff;
    color: #ffffff !important; /* Fallback + override */
    text-decoration: none !important;
}

.btn-primary-custom:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #ffffff !important; /* Keep text white on hover */
}

/* Keep icons/text inside primary custom button white */
.btn-primary-custom i,
.btn-primary-custom .fa,
.btn-primary-custom .fas,
.btn-primary-custom .far,
.btn-primary-custom .fal,
.btn-primary-custom .fab {
    color: #ffffff !important;
}

/* Secondary Custom Button */
.btn-secondary-custom {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    --bs-btn-color: #ffffff;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-active-color: #ffffff;
    --bs-btn-disabled-color: #ffffff;
    color: #ffffff !important;
    text-decoration: none !important;
}

.btn-secondary-custom:hover {
    background-color: var(--secondary-hover);
    border-color: var(--secondary-hover);
    color: #ffffff !important;
}

.btn-outline-secondary-custom {
    background-color: transparent;
    border-color: var(--secondary-color);
    color: var(--secondary-color) !important;
}

.btn-outline-secondary-custom:hover {
    background-color: var(--secondary-bg);
    border-color: var(--secondary-hover);
    color: var(--secondary-hover) !important;
}

/* Text utility classes for secondary color */
.text-secondary-custom {
    color: var(--secondary-color) !important;
}

.bg-secondary-custom {
    background-color: var(--secondary-bg) !important;
}

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

/* Blazor Error UI */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}


/* Global Modal Styles */
.modal.show {
    display: block !important;
}

.modal.fade.show {
    opacity: 1;
}

/* Global Form Validation */
.form-control.is-invalid {
    border-color: var(--danger-color);
}

.invalid-feedback {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Global Loading States */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Global Accessibility */
.btn:focus,
.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(139, 92, 246, 0.25);
    border-color: var(--primary-color);
    outline: 0;
}

.modal-header .btn-close:focus {
    box-shadow: 0 0 0 0.2rem rgba(139, 92, 246, 0.25);
}

/* Global Typography */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--fg, #111827);
    line-height: 1.3;
}

p {
    line-height: 1.7;
    color: var(--fg, #111827);
}

.text-muted {
    color: var(--muted, #6b7280) !important;
}

.lead {
    color: var(--fg, #111827);
}

/* Global Button Enhancements */
.btn {
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn-primary-custom {
    background: linear-gradient(135deg, var(--primary-color) 0%, #6D28D9 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.25);
}

.btn-primary-custom:hover,
.btn-primary-custom:focus {
    background: linear-gradient(135deg, #6D28D9 0%, #5B21B6 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(109, 40, 217, 0.35);
}

.btn-primary-custom:active {
    transform: translateY(0);
}

.btn:active {
    transform: scale(0.98);
}

/* Global Card Styles */
.card {
    border-radius: 12px;
    border: 1px solid var(--border, rgba(17,24,39,0.08));
    background-color: var(--card, rgba(255,255,255,0.85));
    color: var(--fg, #111827);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.card-title {
    color: var(--fg, #111827);
}

.card-body {
    color: var(--fg, #111827);
}

/* Global Focus Styles */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* Global Form Controls */
.form-control,
.form-select {
    background-color: var(--card, rgba(255,255,255,0.85));
    color: var(--fg, #111827);
    border-color: var(--border, rgba(17,24,39,0.08));
}

.form-control:focus,
.form-select:focus {
    background-color: var(--card, rgba(255,255,255,0.85));
    color: var(--fg, #111827);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.form-control::placeholder {
    color: var(--muted, #6b7280);
}

.form-label {
    color: var(--fg, #111827);
}

.form-text {
    color: var(--muted, #6b7280);
}

.form-check-label {
    color: var(--fg, #111827);
}

/* Global Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Global Screen Reader Only */
.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;
}

/* Global Skip Link */
.skip-link {
    position: fixed;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 10001; /* Above everything including navbar and offline indicator */
    opacity: 0; /* Completely hidden by default */
    pointer-events: none; /* Not interactive when hidden */
}

.skip-link:focus {
    top: 0;
    opacity: 1; /* Fully visible when focused */
    pointer-events: auto; /* Interactive when focused */
}

/* Global Button Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Global Responsive Images */
img {
    max-width: 100%;
    height: auto;
}

/* Global Transitions */
.card,
.btn,
.form-control,
.input-group,
.badge,
.progress-bar {
    transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
    transition-duration: 150ms;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile Input Font Size Fix - Prevents Auto-Zoom on iOS */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        font-size: 0.9375rem;
    }

    h1 {
        font-size: 1.875rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    button,
    a {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }

    .modal-dialog {
        margin: 1rem;
    }

    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}

@media (max-width: 576px) {
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 1rem;
    }

    .d-flex.gap-2 {
        flex-wrap: wrap;
    }
}

/* Performance: Hardware Acceleration */
.card,
.btn {
    transform: translateZ(0);
    will-change: transform;
}

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

/* Alert Styles for Dark Mode */
.alert {
    background-color: var(--card, rgba(255,255,255,0.85));
    border-color: var(--border, rgba(17,24,39,0.08));
    color: var(--fg, #111827);
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

html[data-theme="dark"] .alert-danger {
    background-color: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: #059669;
}

html[data-theme="dark"] .alert-success {
    background-color: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
    color: #6ee7b7;
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: #d97706;
}

html[data-theme="dark"] .alert-warning {
    background-color: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fcd34d;
}

.alert-info {
    background-color: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: #2563eb;
}

html[data-theme="dark"] .alert-info {
    background-color: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
    color: #93c5fd;
}

/* HR and Border Styles */
hr, .border-top {
    border-color: var(--border, rgba(17,24,39,0.08)) !important;
}

/* Outline Button Styles for Dark Mode */
@media (prefers-color-scheme: dark) {
    .btn-outline-danger {
        color: #fca5a5;
        border-color: #fca5a5;
    }

    .btn-outline-danger:hover,
    .btn-outline-danger:focus {
        background-color: rgba(239, 68, 68, 0.15);
        border-color: #f87171;
        color: #f87171;
    }

    .btn-outline-primary {
        color: #a5b4fc;
        border-color: #a5b4fc;
    }

    .btn-outline-primary:hover,
    .btn-outline-primary:focus {
        background-color: rgba(99, 102, 241, 0.15);
        border-color: #818cf8;
        color: #818cf8;
    }

    .btn-outline-success {
        color: #6ee7b7;
        border-color: #6ee7b7;
    }

    .btn-outline-success:hover,
    .btn-outline-success:focus {
        background-color: rgba(16, 185, 129, 0.15);
        border-color: #34d399;
        color: #34d399;
    }

    .btn-outline-warning {
        color: #fcd34d;
        border-color: #fcd34d;
    }

    .btn-outline-warning:hover,
    .btn-outline-warning:focus {
        background-color: rgba(245, 158, 11, 0.15);
        border-color: #fbbf24;
        color: #fbbf24;
    }
}

html[data-theme="dark"] .btn-outline-danger {
    color: #fca5a5;
    border-color: #fca5a5;
}

html[data-theme="dark"] .btn-outline-danger:hover,
html[data-theme="dark"] .btn-outline-danger:focus {
    background-color: rgba(239, 68, 68, 0.15);
    border-color: #f87171;
    color: #f87171;
}

html[data-theme="dark"] .btn-outline-primary {
    color: #a5b4fc;
    border-color: #a5b4fc;
}

html[data-theme="dark"] .btn-outline-primary:hover,
html[data-theme="dark"] .btn-outline-primary:focus {
    background-color: rgba(99, 102, 241, 0.15);
    border-color: #818cf8;
    color: #818cf8;
}

html[data-theme="dark"] .btn-outline-success {
    color: #6ee7b7;
    border-color: #6ee7b7;
}

html[data-theme="dark"] .btn-outline-success:hover,
html[data-theme="dark"] .btn-outline-success:focus {
    background-color: rgba(16, 185, 129, 0.15);
    border-color: #34d399;
    color: #34d399;
}

html[data-theme="dark"] .btn-outline-warning {
    color: #fcd34d;
    border-color: #fcd34d;
}

html[data-theme="dark"] .btn-outline-warning:hover,
html[data-theme="dark"] .btn-outline-warning:focus {
    background-color: rgba(245, 158, 11, 0.15);
    border-color: #fbbf24;
    color: #fbbf24;
}

/* Version indicator - subtle, you need to know to look for it */
.version-indicator {
    font-size: 0.65rem;
    opacity: 0.4;
    margin-left: 8px;
    font-family: monospace;
    letter-spacing: 0.5px;
    transition: opacity 0.2s ease;
}

.version-indicator:hover {
    opacity: 0.8;
}
