/* Alddayme Phonetics & Phonology Platform - Academic Laboratory Theme */

:root {
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;
    --primary-dark: #075985;
    
    --bg-page: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    
    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-ipa: 'Lucida Sans Unicode', 'Doulos SIL', 'Charis SIL', 'DejaVu Sans', 'Arial Unicode MS', sans-serif;
}

/* Reset & Strict Box Sizing to prevent horizontal wobble */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography & Direction */
[dir="rtl"] { text-align: right; }
[dir="ltr"] { text-align: left; }

.ipa, .ipa-symbol {
    font-family: var(--font-ipa);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Navigation Bar */
.navbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
    width: 100%;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.65rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: var(--primary-dark);
    font-weight: 800;
    font-size: 1.15rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.15rem;
    list-style: none;
}

.nav-link {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    padding: 0.45rem 0.7rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    font-size: 0.92rem;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Mobile Hamburger Button */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-main);
    transition: all 0.2s ease;
}

.mobile-menu-btn:active {
    transform: scale(0.95);
    background: var(--primary-light);
}

/* Off-canvas Slide-in Sidebar Drawer */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 290px;
    max-width: 82vw;
    background: white;
    z-index: 999;
    box-shadow: -4px 0 25px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
}

/* Slide in from right for RTL, and from left for LTR */
[dir="rtl"] .sidebar-drawer {
    right: 0;
    left: auto;
    transform: translateX(100%);
}

[dir="ltr"] .sidebar-drawer {
    left: 0;
    right: auto;
    transform: translateX(-100%);
}

.sidebar-drawer.active {
    transform: translateX(0) !important;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.15rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.sidebar-close-btn {
    background: white;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-muted);
}

.sidebar-nav-list {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    gap: 0.35rem;
    list-style: none;
}

.sidebar-nav-list .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    color: var(--text-main);
}

.sidebar-nav-list .nav-link:hover, .sidebar-nav-list .nav-link.active {
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* Floating Action Button for Language Switch */
.floating-lang-btn {
    position: fixed;
    bottom: 22px;
    left: 20px;
    z-index: 997;
    background: white;
    color: var(--primary-dark);
    border: 1.5px solid var(--primary-light);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border-radius: 50px;
    padding: 0.45rem 0.95rem;
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

[dir="ltr"] .floating-lang-btn {
    left: auto;
    right: 20px;
}

.floating-lang-btn:hover, .floating-lang-btn:active {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.25);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-outline { background: transparent; color: var(--text-main); border-color: var(--border); }
.btn-outline:hover { background: var(--bg-page); border-color: var(--border-hover); }

.btn-secondary { background: var(--primary-light); color: var(--primary-dark); }
.btn-secondary:hover { background: #bae6fd; }

.btn-success { background: var(--success); color: white; }

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.82rem;
}

.btn-sound {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid #bae6fd;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.btn-sound:hover, .btn-sound:active {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

/* Flash Messages */
.messages-container {
    max-width: 1200px;
    margin: 0.75rem auto 0;
    padding: 0 1rem;
    width: 100%;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.6rem;
    font-size: 0.9rem;
}

.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-info { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #bae6fd; }
.alert-danger, .alert-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }

/* Main Content Wrapper */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 1.25rem auto 2.5rem;
    padding: 0 1.25rem;
}

/* Cards & Grid */
.grid {
    display: grid;
    gap: 1.25rem;
}

.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    width: 100%;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

/* IPA Interactive Chart Table */
.ipa-table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
    background: white;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: block;
}

.ipa-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    min-width: 580px;
}

.ipa-table th, .ipa-table td {
    border: 1px solid var(--border);
    padding: 0.55rem 0.65rem;
    text-align: center;
}

.ipa-table th {
    background: #f1f5f9;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.82rem;
}

.ipa-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-ipa);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-dark);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    cursor: pointer;
    margin: 2px;
}

.ipa-badge.voiceless {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.ipa-badge:active {
    transform: scale(0.95);
    background: var(--primary-light);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-main);
}

.form-input, .form-select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: white;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* Exercise / Quiz UI */
.exercise-box {
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    cursor: pointer;
    font-size: 0.92rem;
    transition: all 0.15s ease;
}

.option-btn:active, .option-btn.selected {
    background: var(--primary-light);
    border-color: var(--primary);
    font-weight: 600;
}

/* Flashcard */
.flashcard {
    min-height: 200px;
    background: white;
    border: 1.5px solid var(--primary-light);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease;
}

/* Footer */
.footer {
    background: white;
    border-top: 1px solid var(--border);
    padding: 1.25rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: auto;
    width: 100%;
}

/* ==============================================================
   RESPONSIVE DESIGN RULES FOR MOBILE (Clean, Compact, No Overflow)
   ============================================================== */
@media (max-width: 768px) {
    html, body {
        font-size: 14px;
    }

    body {
        padding-bottom: 30px;
    }

    .main-content {
        margin: 0.65rem auto 1.25rem;
        padding: 0 0.65rem;
    }

    .nav-container {
        padding: 0.65rem 0.85rem;
    }

    .nav-links {
        display: none !important;
    }

    .mobile-menu-btn {
        display: inline-flex !important;
        margin-inline-end: 0.25rem;
    }

    .grid-cols-2, .grid-cols-3, .grid-cols-4 {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
    }

    .card {
        padding: 0.95rem !important;
        border-radius: var(--radius-sm) !important;
    }

    .card-title {
        font-size: 1.05rem !important;
    }

    .brand img {
        height: 34px !important;
    }

    .brand span {
        font-size: 0.92rem !important;
    }

    /* Scale down oversized hero headings and badges */
    .hero-banner h1 {
        font-size: 1.35rem !important;
        line-height: 1.4 !important;
    }

    .hero-banner p {
        font-size: 0.9rem !important;
        line-height: 1.55 !important;
        margin-bottom: 1.25rem !important;
    }

    .hero-banner {
        padding: 1.5rem 1rem !important;
        margin-bottom: 1.25rem !important;
    }

    .btn {
        padding: 0.45rem 0.85rem;
        font-size: 0.85rem;
    }

    .btn-sound {
        width: 36px !important;
        height: 36px !important;
    }

    .ipa-badge {
        font-size: 1rem !important;
        padding: 0.25rem 0.55rem !important;
        min-height: 36px;
        min-width: 36px;
    }

    .option-btn {
        padding: 0.65rem 0.85rem !important;
        font-size: 0.88rem !important;
    }

    .exercise-box {
        padding: 1rem !important;
    }
}
