/* ==========================================================================
   MMPI DESIGN SYSTEM (VANILLA CSS) - SPOTIFY & APPLE STYLE
   ========================================================================== */

/* --- Custom Variables & Themes --- */
:root {
    --dir-sign: 1;
}

[dir="rtl"] {
    --dir-sign: -1;
}

:root[data-theme="dark"] {
    --bg-primary: #0a0b10;
    --bg-secondary: #12131a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --card-bg: rgba(20, 22, 33, 0.65);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-hover-border: rgba(99, 102, 241, 0.35);
    --input-bg: rgba(15, 17, 26, 0.6);
    --input-border: rgba(255, 255, 255, 0.1);
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --accent: #06b6d4;
    --success: #10b981;
    --error: #ef4444;
    --nav-bg: rgba(10, 11, 16, 0.75);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glow-1: rgba(99, 102, 241, 0.15);
    --glow-2: rgba(168, 85, 247, 0.15);
}

:root[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(0, 0, 0, 0.06);
    --card-hover-border: rgba(99, 102, 241, 0.4);
    --input-bg: rgba(255, 255, 255, 0.9);
    --input-border: rgba(0, 0, 0, 0.1);
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --accent: #0891b2;
    --success: #059669;
    --error: #dc2626;
    --nav-bg: rgba(248, 250, 252, 0.8);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.06);
    --glow-1: rgba(79, 70, 229, 0.08);
    --glow-2: rgba(124, 58, 237, 0.08);
}

/* --- Reset & Global --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100%;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

[dir="rtl"] body {
    font-family: 'Cairo', 'Outfit', sans-serif;
}

/* --- Ambient Glowing Effects --- */
.ambient-glow {
    position: absolute;
    width: 45vw;
    height: 45vw;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    pointer-events: none;
}
.bg-glow-1 {
    top: -10%;
    left: -10%;
    background: var(--glow-1);
}
.bg-glow-2 {
    bottom: -10%;
    right: -10%;
    background: var(--glow-2);
}

/* --- Typography Helpers --- */
.text-gradient {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* --- Layout Containers --- */
.header-container, .content-container, .footer-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* --- Header / Navigation --- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--nav-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--card-border);
    height: 72px;
    display: flex;
    align-items: center;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo-image {
    height: 38px;
    width: auto;
    object-fit: contain;
}

.nav-menu {
    display: flex;
    gap: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

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

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

/* Action Button */
.action-btn {
    background: none;
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn:hover {
    color: var(--text-primary);
    border-color: var(--primary);
    background-color: var(--card-border);
}

/* Dropdown Language */
.lang-dropdown {
    position: relative;
    display: inline-block;
}

.lang-dropdown button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    width: auto;
}

.lang-dropdown::after {
    content: "";
    position: absolute;
    top: 100%;
    inset-inline-end: 0;
    min-width: 120px;
    width: 100%;
    height: 15px;
    background: transparent;
    display: none;
    z-index: 1;
}

.lang-dropdown:hover::after {
    display: block;
}

.dropdown-content {
    display: none;
    position: absolute;
    inset-inline-end: 0;
    top: 100%;
    background-color: var(--bg-secondary);
    border: 1px solid var(--card-border);
    min-width: 120px;
    box-shadow: var(--shadow);
    border-radius: 12px;
    z-index: 1;
    overflow: hidden;
    margin-top: 6px;
}

.dropdown-content a {
    color: var(--text-primary);
    padding: 10px 16px;
    text-decoration: none;
    display: block;
    font-size: 13px;
    transition: background 0.3s;
}

.dropdown-content a:hover {
    background-color: var(--card-border);
}

.lang-dropdown:hover .dropdown-content {
    display: block;
}

/* User Profile Info */
.user-profile-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    transition: color 0.3s ease;
}

.user-name:hover {
    color: var(--primary);
}

/* --- Theme Toggle Icons --- */
:root[data-theme="dark"] .light-icon { display: none; }
:root[data-theme="dark"] .dark-icon { display: inline-block; }
:root[data-theme="light"] .light-icon { display: inline-block; }
:root[data-theme="light"] .dark-icon { display: none; }

/* --- App Footer --- */
.app-footer {
    border-top: 1px solid var(--card-border);
    padding: 24px 0;
    margin-top: auto;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    flex-shrink: 0;
}

/* --- Main Layout --- */
.app-main {
    flex: 1 0 auto;
    padding: 40px 0;
}

/* --- Cards (Glassmorphism) --- */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 32px;
    box-shadow: var(--shadow);
    transition: border-color 0.3s ease, transform 0.3s ease;
}

.card:hover {
    border-color: var(--card-hover-border);
}

.card-header {
    margin-bottom: 24px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 16px;
}

.card-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.card-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(99, 102, 241, 0.5);
    opacity: 0.95;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-primary);
}

.btn-outline:hover {
    background-color: var(--card-border);
    border-color: var(--text-secondary);
    transform: translateY(-2px);
}

.btn-sm {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 32px;
    border-radius: 14px;
    font-size: 16px;
}

.btn-success {
    background-color: var(--success);
    color: #ffffff;
}
.btn-success:hover {
    background-color: #059669;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* --- Alerts & Notifications --- */
.alert {
    padding: 16px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    font-size: 14px;
    font-weight: 500;
    border-inline-start: 4px solid transparent;
    position: relative;
}

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

.alert-error {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border-color: var(--error);
}

.alert-close {
    margin-inline-start: auto;
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
}

/* --- Form Fields --- */
.form-group {
    margin-bottom: 20px;
}

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

.form-control {
    width: 100%;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Custom Grid */
.grid {
    display: grid;
    gap: 24px;
}

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

/* --- Auth Pages Custom Styles --- */
.auth-card {
    max-width: 480px;
    margin: 40px auto;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 28px;
    font-weight: 800;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* --- MMPI TEST ENGINE UI --- */
.test-layout {
    max-width: 900px;
    margin: 0 auto;
}

.test-progress-container {
    position: sticky;
    top: 72px;
    background-color: var(--bg-primary);
    padding: 20px 0;
    z-index: 10;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 32px;
}

.test-progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.progress-bar-bg {
    width: 100%;
    height: 10px;
    background-color: var(--card-border);
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary-gradient);
    width: 0%;
    transition: width 0.4s ease;
}

.question-item {
    padding: 24px;
    border-radius: 12px;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
}

.question-item:hover {
    border-color: var(--card-hover-border);
    transform: translateX(calc(4px * var(--dir-sign, 1)));
}

.question-number {
    font-size: 16px;
    font-weight: 800;
    color: var(--primary);
    min-width: 32px;
}

.question-text {
    font-size: 15px;
    font-weight: 500;
    flex: 1;
}

.answer-options {
    display: flex;
    gap: 8px;
}

.answer-btn {
    border: 1px solid var(--card-border);
    background: var(--input-bg);
    color: var(--text-secondary);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.answer-btn.btn-true:hover {
    border-color: var(--success);
    color: var(--success);
    background-color: rgba(16, 185, 129, 0.05);
}

.answer-btn.btn-false:hover {
    border-color: var(--error);
    color: var(--error);
    background-color: rgba(239, 68, 68, 0.05);
}

.answer-btn.selected-true {
    background-color: var(--success);
    color: #ffffff;
    border-color: var(--success);
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.answer-btn.selected-false {
    background-color: var(--error);
    color: #ffffff;
    border-color: var(--error);
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
}

.pagination-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 32px;
}

/* --- ADMIN DASHBOARD --- */
.widget {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.widget-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: var(--primary-gradient);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.25);
}

.widget-info h3 {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.widget-info .widget-value {
    font-size: 28px;
    font-weight: 800;
    margin-top: 4px;
}

/* Modern Tables */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    background: var(--card-bg);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: start;
    font-size: 14px;
}

.admin-table th {
    background-color: rgba(255, 255, 255, 0.02);
    padding: 16px 20px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--card-border);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.admin-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--card-border);
    color: var(--text-primary);
}

.admin-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    box-shadow: var(--shadow);
    animation: scale-up 0.3s ease;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--card-border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* --- Animation keyframes --- */
@keyframes scale-up {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

.animate-fade-in {
    animation: fade-in 0.3s ease forwards;
}

/* --- Responsive Media Queries --- */
@media (max-width: 992px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
    .header-container {
        flex-direction: column;
        gap: 16px;
        height: auto;
        padding: 16px 24px;
    }
    .app-header {
        height: auto;
    }
    .nav-menu {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    .header-actions {
        width: 100%;
        justify-content: center;
    }
    .question-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .answer-options {
        width: 100%;
        justify-content: flex-end;
        margin-top: 12px;
    }
}
