/* ============================================
   MBA Lernfragen - iOS-Style Theme
   ============================================ */

:root {
    --ios-bg: #F2F2F7;
    --ios-card: #FFFFFF;
    --ios-separator: rgba(60, 60, 67, 0.12);
    --ios-text: #1C1C1E;
    --ios-text-secondary: #8E8E93;
    --ios-blue: #007AFF;
    --ios-green: #34C759;
    --ios-red: #FF3B30;
    --ios-orange: #FF9500;
    --ios-yellow: #FFCC00;
    --ios-teal: #5AC8FA;
    --ios-purple: #AF52DE;
    --ios-radius: 12px;
    --ios-radius-sm: 10px;
    --ios-radius-lg: 16px;
    --ios-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --ios-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.1);
    --ios-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
    --ios-nav-blur: saturate(180%) blur(20px);
    --ios-nav-bg: rgba(249, 249, 249, 0.94);
    --ios-group-bg: #FFFFFF;
    --ios-group-header: #6D6D72;
}

[data-bs-theme="dark"] {
    --ios-bg: #000000;
    --ios-card: #1C1C1E;
    --ios-separator: rgba(84, 84, 88, 0.65);
    --ios-text: #FFFFFF;
    --ios-text-secondary: #8E8E93;
    --ios-nav-bg: rgba(29, 29, 31, 0.94);
    --ios-group-bg: #1C1C1E;
    --ios-group-header: #8E8E93;
    --ios-shadow: none;
    --ios-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Typography */
body {
    font-family: var(--ios-font);
    color: var(--ios-text);
    background-color: var(--ios-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 9999;
    padding: 0.5rem 1rem;
    background: var(--ios-blue);
    color: #fff;
    border-radius: var(--ios-radius-sm);
}

.skip-link:focus {
    top: 0.5rem;
}

/* ── iOS Navigation Bar ────────────────────── */
.app-navbar {
    background: var(--ios-nav-bg) !important;
    -webkit-backdrop-filter: var(--ios-nav-blur);
    backdrop-filter: var(--ios-nav-blur);
    border-bottom: 0.5px solid var(--ios-separator) !important;
    box-shadow: none;
    padding: 0.5rem 0;
}

.app-navbar .navbar-brand {
    color: var(--ios-blue);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

[data-bs-theme="dark"] .app-navbar .navbar-brand {
    color: var(--ios-blue);
}

.app-navbar .nav-link {
    color: var(--ios-blue);
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: var(--ios-radius-sm);
    padding: 0.4rem 0.75rem !important;
    transition: background-color 0.15s ease;
}

.app-navbar .nav-link:hover {
    background-color: rgba(0, 122, 255, 0.08);
}

/* ── iOS Cards / Grouped Style ─────────────── */
.card {
    border: none;
    border-radius: var(--ios-radius);
    box-shadow: var(--ios-shadow);
    background-color: var(--ios-card);
    overflow: hidden;
}

.card-header {
    border-radius: var(--ios-radius) var(--ios-radius) 0 0 !important;
    border-bottom: 0.5px solid var(--ios-separator);
}

/* Topic cards on dashboard */
.topic-card {
    transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
    border-left: 4px solid var(--ios-blue);
    border-radius: var(--ios-radius);
}

.topic-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ios-shadow-hover) !important;
}

/* ── Progress bars ─────────────────────────── */
.progress {
    border-radius: 999px;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.04);
    height: 6px;
}

[data-bs-theme="dark"] .progress {
    background-color: rgba(255, 255, 255, 0.08);
}

.progress-bar.bg-success {
    background-color: var(--ios-green) !important;
}

/* ── Buttons ───────────────────────────────── */
.btn {
    border-radius: var(--ios-radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    transition: transform 0.1s ease-out, opacity 0.1s ease-out, background-color 0.15s ease;
    letter-spacing: -0.01em;
}

.btn:active {
    transform: scale(0.97);
    opacity: 0.85;
}

.btn-primary {
    background-color: var(--ios-blue);
    border-color: var(--ios-blue);
}

.btn-primary:hover {
    background-color: #0056CC;
    border-color: #0056CC;
}

.btn-success {
    background-color: var(--ios-green);
    border-color: var(--ios-green);
}

.btn-danger {
    background-color: var(--ios-red);
    border-color: var(--ios-red);
}

.btn-warning {
    background-color: var(--ios-orange);
    border-color: var(--ios-orange);
    color: #fff;
}

.btn-warning:hover {
    color: #fff;
}

.btn-outline-primary {
    color: var(--ios-blue);
    border-color: var(--ios-blue);
}

.btn-outline-primary:hover,
.btn-outline-primary.active {
    background-color: var(--ios-blue);
    border-color: var(--ios-blue);
}

.btn-outline-secondary {
    color: var(--ios-text-secondary);
    border-color: var(--ios-separator);
}

.btn-outline-success {
    color: var(--ios-green);
    border-color: var(--ios-green);
}

.btn-outline-success:hover {
    background-color: var(--ios-green);
    border-color: var(--ios-green);
}

/* Rating buttons */
.rating-btn {
    min-width: 110px;
    border-radius: var(--ios-radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
}

/* MC option buttons */
.mc-option {
    border-radius: var(--ios-radius-sm) !important;
    border: 2px solid var(--ios-separator);
    background: var(--ios-card);
    color: var(--ios-text);
    transition: transform 0.1s ease-out, border-color 0.15s ease, background-color 0.15s ease;
    text-align: left;
    padding: 0.875rem 1rem;
    min-height: 44px;
}

.mc-option:hover:not(:disabled) {
    border-color: var(--ios-blue);
    transform: translateX(3px);
    background: var(--ios-card);
    color: var(--ios-text);
}

.mc-option.btn-success {
    border-color: var(--ios-green);
    background-color: rgba(52, 199, 89, 0.1);
}

.mc-option.btn-danger {
    border-color: var(--ios-red);
    background-color: rgba(255, 59, 48, 0.1);
}

.mc-option.mc-selected {
    border-color: var(--ios-blue);
    background-color: rgba(0, 122, 255, 0.08);
}

[data-bs-theme="dark"] .mc-option.mc-selected {
    background-color: rgba(0, 122, 255, 0.2);
}

.mc-checkbox {
    font-size: 1.1em;
    vertical-align: middle;
}

/* ── Badges ────────────────────────────────── */
.badge {
    font-weight: 500;
    letter-spacing: 0.01em;
    border-radius: 6px;
    font-size: 0.78rem;
}

.text-bg-primary { background-color: var(--ios-blue) !important; }
.text-bg-success { background-color: var(--ios-green) !important; }
.text-bg-danger { background-color: var(--ios-red) !important; }
.text-bg-warning { background-color: var(--ios-orange) !important; color: #fff !important; }
.text-bg-info { background-color: var(--ios-teal) !important; }
.text-bg-secondary { background-color: var(--ios-text-secondary) !important; }

/* ── Answer content ────────────────────────── */
.answer-content h1,
.answer-content h2,
.answer-content h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-top: 0.8rem;
    margin-bottom: 0.4rem;
    letter-spacing: -0.01em;
}

.answer-content ul,
.answer-content ol {
    padding-left: 1.5rem;
}

.answer-content table {
    width: 100%;
    margin: 0.5rem 0;
    border-radius: var(--ios-radius-sm);
    overflow: hidden;
}

.answer-content table th,
.answer-content table td {
    padding: 0.5rem 0.75rem;
    border: 0.5px solid var(--ios-separator);
    font-size: 0.92rem;
}

.answer-content table th {
    background-color: rgba(0, 0, 0, 0.03);
    font-weight: 600;
}

[data-bs-theme="dark"] .answer-content table th {
    background-color: rgba(255, 255, 255, 0.05);
}

/* ── Loading skeleton ──────────────────────── */
.skeleton {
    background: linear-gradient(90deg,
        var(--ios-separator) 25%,
        rgba(0, 0, 0, 0.04) 50%,
        var(--ios-separator) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: var(--ios-radius-sm);
}

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
    width: 80%;
}

.skeleton-text:last-child {
    width: 60%;
}

/* ── Animations ────────────────────────────── */
.question-enter {
    animation: fadeSlideIn 0.25s ease-out;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.feedback-flash {
    animation: feedbackPop 0.3s ease-out;
}

@keyframes feedbackPop {
    0% { transform: scale(0.95); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.done-icon {
    font-size: 4rem;
    animation: celebratePop 0.5s ease-out;
}

@keyframes celebratePop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.counter-update {
    animation: counterPulse 0.3s ease-out;
}

@keyframes counterPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

/* Stats bars */
.stats-bars .d-flex > div {
    transition: width 0.3s ease-out;
}

/* ── Stat Cards (Dashboard) ────────────────── */
.stat-card {
    border-radius: var(--ios-radius);
    border: none;
    background: var(--ios-card);
    box-shadow: var(--ios-shadow);
    text-align: center;
}

.stat-card .h4 {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* ── Streak Widget ─────────────────────────── */
.streak-widget {
    background: linear-gradient(135deg, #FF9500, #FF3B30);
    color: #fff;
    border-radius: var(--ios-radius-lg);
    padding: 1.25rem;
    text-align: center;
}

[data-bs-theme="dark"] .streak-widget {
    background: linear-gradient(135deg, #CC7700, #CC2F26);
}

.streak-number {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.streak-label {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.9;
    margin-top: 0.25rem;
}

.streak-goal {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
}

.streak-goal .progress {
    height: 8px;
    background-color: rgba(255, 255, 255, 0.25);
}

.streak-goal .progress-bar {
    background-color: #fff;
}

/* ── Learning History Chart ────────────────── */
.chart-container {
    background: var(--ios-card);
    border-radius: var(--ios-radius);
    padding: 1rem;
    box-shadow: var(--ios-shadow);
}

.chart-container canvas {
    max-height: 200px;
}

/* ── Auth Cards ────────────────────────────── */
.auth-card {
    border-top: 4px solid var(--ios-blue);
    border-radius: var(--ios-radius);
}

/* ── Form Elements ─────────────────────────── */
.form-control {
    border-radius: var(--ios-radius-sm);
    border: 1px solid var(--ios-separator);
    padding: 0.625rem 0.875rem;
    font-size: 0.95rem;
    min-height: 44px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    border-color: var(--ios-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.form-check-input {
    border-radius: 6px;
    min-width: 22px;
    min-height: 22px;
}

.form-check-input:checked {
    background-color: var(--ios-blue);
    border-color: var(--ios-blue);
}

.form-select {
    border-radius: var(--ios-radius-sm);
    min-height: 44px;
    border: 1px solid var(--ios-separator);
}

/* Quiz textarea */
#user-answer {
    font-size: 1rem;
    border-radius: var(--ios-radius-sm);
    min-height: 120px;
}

#user-answer:focus {
    border-color: var(--ios-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

#user-answer-display {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    font-size: 0.95rem;
}

/* ── Tables (iOS grouped style) ────────────── */
.table {
    --bs-table-bg: var(--ios-card);
    border-radius: var(--ios-radius);
    overflow: hidden;
    font-size: 0.92rem;
}

.table > :not(caption) > * > * {
    border-bottom-color: var(--ios-separator);
    padding: 0.75rem 1rem;
}

.table > thead > tr > th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ios-text-secondary);
    border-bottom-width: 0.5px;
    background: transparent;
}

/* ── Alerts ────────────────────────────────── */
.alert {
    border-radius: var(--ios-radius-sm);
    border: none;
    font-size: 0.92rem;
}

/* ── Dropdown ──────────────────────────────── */
.dropdown-menu {
    border-radius: var(--ios-radius);
    border: 0.5px solid var(--ios-separator);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 0.25rem;
    overflow: hidden;
}

.dropdown-item {
    border-radius: var(--ios-radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.92rem;
}

.dropdown-item:hover {
    background-color: rgba(0, 122, 255, 0.08);
}

/* ── Modal (iOS Action Sheet style) ────────── */
.modal-content {
    border-radius: var(--ios-radius-lg);
    border: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 0.5px solid var(--ios-separator);
    padding: 1rem 1.25rem;
}

.modal-header .modal-title {
    font-weight: 600;
    font-size: 1rem;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    border-top: 0.5px solid var(--ios-separator);
    padding: 0.75rem 1.25rem;
}

/* ── Footer ────────────────────────────────── */
footer {
    background-color: var(--ios-card);
    border-top: 0.5px solid var(--ios-separator) !important;
}

/* ── Admin Sidebar ─────────────────────────── */
.list-group-item {
    border-color: var(--ios-separator);
    font-size: 0.92rem;
    padding: 0.75rem 1rem;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.list-group-item.active {
    background-color: var(--ios-blue);
    border-color: var(--ios-blue);
}

/* ── Responsive ────────────────────────────── */
@media (max-width: 576px) {
    .rating-btn {
        min-width: 75px;
        font-size: 0.82rem;
        padding: 0.5rem 0.6rem;
    }

    h1, .h1 { font-size: 1.5rem; }
    h2, .h2 { font-size: 1.25rem; }

    .stat-card .h4 { font-size: 1.25rem; }

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

/* ── Reduced motion ────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .question-enter,
    .feedback-flash,
    .done-icon,
    .counter-update,
    .skeleton {
        animation: none;
    }

    .topic-card,
    .mc-option,
    .btn {
        transition: none;
    }
}
