/* assets/css/common.css - Matrixo Design System & Tokens (Mobile Portrait First) */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Outfit:wght@400;500;600;700;800;900&display=swap');

:root {
    --bg-dark: #0A0D25;
    --bg-surface: #12173D;
    --bg-card: rgba(26, 33, 84, 0.85);
    --bg-card-hover: rgba(38, 48, 120, 0.95);
    --border-neon: rgba(120, 150, 255, 0.25);
    --border-highlight: #4F8EFF;

    /* Theme Accent Colors from Matrixo.pro Image */
    --neon-blue: #00D2FF;
    --neon-purple: #9D4EDD;
    --neon-yellow: #FFD200;
    --neon-orange: #FF8500;
    --neon-green: #00F59B;
    --neon-pink: #FF3399;

    /* Text */
    --text-white: #FFFFFF;
    --text-dim: #A5B4FC;
    --text-muted: #64748B;
    
    /* Font */
    --font-heading: 'Fredoka', 'Outfit', system-ui, -apple-system, sans-serif;
    --font-body: 'Outfit', system-ui, -apple-system, sans-serif;

    /* Elevation & Glow */
    --glow-yellow: 0 0 15px rgba(255, 210, 0, 0.45);
    --glow-blue: 0 0 15px rgba(0, 210, 255, 0.45);
    --glow-green: 0 0 15px rgba(0, 245, 155, 0.45);
    --glow-pink: 0 0 15px rgba(255, 51, 153, 0.45);
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);

    /* Safe Area */
    --sat: env(safe-area-inset-top, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    min-height: 100vh;
    background-color: var(--bg-dark);
    color: var(--text-white);
    font-family: var(--font-body);
    overflow-x: hidden;
    position: relative;
    padding-top: var(--sat);
    padding-bottom: var(--sab);
}

/* Background Cosmic Grid Pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 50% 10%, rgba(157, 78, 221, 0.2), transparent 45%),
        radial-gradient(circle at 10% 80%, rgba(0, 210, 255, 0.15), transparent 40%),
        radial-gradient(circle at 90% 70%, rgba(255, 133, 0, 0.15), transparent 40%),
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 100% 100%, 40px 40px, 40px 40px;
    background-position: center;
    pointer-events: none;
    z-index: 0;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: 0.5px;
}

a {
    color: var(--neon-blue);
    text-decoration: none;
    transition: all 0.2s;
}

/* Base Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 14px;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    outline: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
    min-height: 44px; /* Touch target >= 42px */
    touch-action: manipulation;
    user-select: none;
}

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

.btn-primary {
    background: linear-gradient(135deg, #FFD200 0%, #FF8500 100%);
    color: #1E1B4B;
    box-shadow: 0 4px 15px rgba(255, 133, 0, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.4);
    border: 2px solid #FFE57F;
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 6px 20px rgba(255, 210, 0, 0.6);
}

.btn-cyan {
    background: linear-gradient(135deg, #00D2FF 0%, #0077FF 100%);
    color: #FFFFFF;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.3);
    border: 2px solid #80EAFF;
}

.btn-cyan:hover {
    filter: brightness(1.1);
    box-shadow: 0 6px 20px rgba(0, 210, 255, 0.6);
}

.btn-success {
    background: linear-gradient(135deg, #00F59B 0%, #059669 100%);
    color: #064E3B;
    box-shadow: 0 4px 15px rgba(0, 245, 155, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.3);
    border: 2px solid #6EE7B7;
}

.btn-danger {
    background: linear-gradient(135deg, #FF3366 0%, #BE123C 100%);
    color: #FFFFFF;
    box-shadow: 0 4px 15px rgba(255, 51, 102, 0.4);
    border: 1px solid #FDA4AF;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #E2E8F0;
    border: 1px solid var(--border-neon);
    backdrop-filter: blur(8px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.18);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
    min-height: 36px;
    border-radius: 10px;
}

/* Form Inputs */
.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dim);
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    background: rgba(14, 19, 53, 0.8);
    border: 1.5px solid var(--border-neon);
    border-radius: 12px;
    color: var(--text-white);
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.form-control:focus {
    border-color: var(--neon-blue);
    box-shadow: 0 0 12px rgba(0, 210, 255, 0.3);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 7, 24, 0.75);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: linear-gradient(165deg, #151A46 0%, #0F1336 100%);
    border: 2px solid var(--border-highlight);
    border-radius: 24px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(79, 142, 255, 0.2);
    position: relative;
    padding: 24px;
    transform: translateY(20px) scale(0.97);
    transition: transform 0.25s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
}

.modal-title {
    font-size: 1.35rem;
    color: var(--neon-yellow);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: none;
    border: none;
    color: #94A3B8;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 8px;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--neon-pink);
}

/* Toast System */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 90vw;
    pointer-events: none;
}

.toast {
    padding: 14px 20px;
    border-radius: 14px;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
    pointer-events: auto;
}

.toast.success {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    border: 1.5px solid #34D399;
    color: #FFFFFF;
}

.toast.error {
    background: linear-gradient(135deg, #DC2626 0%, #991B1B 100%);
    border: 1.5px solid #F87171;
    color: #FFFFFF;
}

.toast.info {
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    border: 1.5px solid #60A5FA;
    color: #FFFFFF;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Table Responsive Container */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 14px;
    border: 1px solid var(--border-neon);
    background: rgba(10, 14, 40, 0.6);
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: left;
}

.custom-table th {
    background: rgba(30, 41, 100, 0.6);
    color: var(--neon-blue);
    padding: 12px 14px;
    font-family: var(--font-heading);
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-neon);
}

.custom-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    white-space: nowrap;
}

.custom-table tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

/* Sound Toggle Button & 3D UI Icons */
.btn-sfx-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid var(--border-neon);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    padding: 0;
    touch-action: manipulation;
}
.btn-sfx-toggle:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: var(--neon-blue);
    transform: scale(1.08);
    box-shadow: 0 0 12px rgba(0, 210, 255, 0.35);
}
.btn-sfx-toggle:active {
    transform: scale(0.92);
}
.btn-sfx-toggle img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    transition: filter 0.25s ease, opacity 0.25s ease;
    pointer-events: none;
}
.btn-sfx-toggle.muted {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.03);
}
.btn-sfx-toggle.muted img {
    filter: grayscale(1) opacity(0.35) !important;
}

.ui-3d-icon {
    display: inline-block;
    vertical-align: middle;
    object-fit: contain;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.4));
}

/* ==================================================== */
/* QUESTION & CHOICES LAYOUT SELECTOR MODAL             */
/* ==================================================== */
.btn-layout-selector {
    position: relative;
    flex-shrink: 0;
    width: 48px;
    height: auto;
    min-height: 46px;
    background: rgba(14, 19, 53, 0.85);
    border: 1.5px solid rgba(0, 245, 155, 0.45);
    border-radius: 14px;
    padding: 6px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}
.btn-layout-selector:hover {
    border-color: var(--neon-teal);
    transform: scale(1.05) translateY(-1px);
    box-shadow: 0 0 16px rgba(0, 245, 155, 0.5);
    background: rgba(20, 28, 72, 0.95);
}
.btn-layout-selector:active {
    transform: scale(0.95);
}
.btn-layout-selector img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* Layout Option Cards in Modal */
.layout-options-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}
@media (max-width: 580px) {
    .layout-options-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
}

.layout-option-card {
    cursor: pointer;
    padding: 8px 6px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.08);
    text-align: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}
.layout-option-card:hover {
    border-color: rgba(0, 245, 155, 0.5);
    background: rgba(0, 245, 155, 0.05);
    transform: translateY(-2px);
}
.layout-option-card.active {
    border-color: var(--neon-teal) !important;
    background: rgba(0, 245, 155, 0.12) !important;
    box-shadow: 0 0 16px rgba(0, 245, 155, 0.4);
    transform: translateY(-2px);
}
.layout-option-card .layout-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-dim);
    margin-top: 4px;
    transition: color 0.2s;
}
.layout-option-card.active .layout-label {
    color: var(--neon-teal) !important;
}

/* Live Mobile Mockup Preview */
.layout-preview-viewport {
    background: #06091F;
    border: 2px solid rgba(0, 245, 155, 0.35);
    border-radius: 22px;
    padding: 12px 14px;
    max-width: 310px;
    height: 330px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), inset 0 0 30px rgba(0, 0, 0, 0.5);
}

.preview-active-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
}
.preview-question-card {
    background: linear-gradient(165deg, rgba(22, 28, 76, 0.95) 0%, rgba(13, 17, 48, 0.98) 100%);
    border: 1.5px solid var(--theme-primary, #00D2FF);
    border-radius: 14px;
    padding: 12px 10px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    transition: all 0.2s;
}
.preview-question-text {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
    margin-top: 2px;
}
.preview-choices-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    transition: all 0.2s;
}
.preview-choice-btn {
    min-height: 40px;
    border-radius: 10px;
    background: linear-gradient(165deg, #1A2154 0%, #11163D 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

/* Preview Layout 1: 40% Question, 60% Choices */
.preview-active-section.layout-style-1 { 
    display: flex; 
    flex-direction: column; 
    justify-content: space-between; 
    gap: 8px; 
    height: 100%;
}
.preview-active-section.layout-style-1 .preview-question-card { 
    order: 1; 
    flex: 4; 
    min-height: 0;
    margin: 0; 
    padding: 10px; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
}
.preview-active-section.layout-style-1 .preview-choices-grid { 
    order: 2; 
    flex: 6; 
    min-height: 0;
    margin: 0; 
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 6px;
}
.preview-active-section.layout-style-1 .preview-choice-btn { 
    height: 100%; 
    min-height: 0; 
}

/* Preview Layout 2 */
.preview-active-section.layout-style-2 { justify-content: space-between; }
.preview-active-section.layout-style-2 .preview-question-card { order: 1; margin: 4px 0; padding: 8px; border-radius: 10px; }
.preview-active-section.layout-style-2 .preview-question-text { font-size: 1.15rem; }
.preview-active-section.layout-style-2 .preview-choices-grid { order: 2; margin-top: auto; margin-bottom: 6px; gap: 6px; }
.preview-active-section.layout-style-2 .preview-choice-btn { min-height: 32px; font-size: 0.95rem; border-radius: 8px; }

/* Preview Layout 3 */
.preview-active-section.layout-style-3 { justify-content: flex-start; }
.preview-active-section.layout-style-3 .preview-question-card { order: 1; margin: 4px 0 8px 0; padding: 8px; border-radius: 10px; }
.preview-active-section.layout-style-3 .preview-question-text { font-size: 1.15rem; }
.preview-active-section.layout-style-3 .preview-choices-grid { order: 2; margin-top: 0; margin-bottom: 0; gap: 6px; }
.preview-active-section.layout-style-3 .preview-choice-btn { min-height: 32px; font-size: 0.95rem; border-radius: 8px; }

/* Preview Layout 4: 60% Choices, 40% Question */
.preview-active-section.layout-style-4 { 
    display: flex; 
    flex-direction: column; 
    justify-content: space-between; 
    gap: 8px; 
    height: 100%;
}
.preview-active-section.layout-style-4 .preview-choices-grid { 
    order: 1; 
    flex: 6; 
    min-height: 0;
    margin: 0; 
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 6px;
}
.preview-active-section.layout-style-4 .preview-choice-btn { 
    height: 100%; 
    min-height: 0; 
}
.preview-active-section.layout-style-4 .preview-question-card { 
    order: 2; 
    flex: 4; 
    min-height: 0;
    margin: 0; 
    padding: 10px; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
}

/* Preview Layout 5 */
.preview-active-section.layout-style-5 { justify-content: space-between; }
.preview-active-section.layout-style-5 .preview-choices-grid { order: 1; margin-top: 4px; margin-bottom: auto; gap: 6px; }
.preview-active-section.layout-style-5 .preview-choice-btn { min-height: 32px; font-size: 0.95rem; border-radius: 8px; }
.preview-active-section.layout-style-5 .preview-question-card { order: 2; margin: 4px 0; padding: 8px; border-radius: 10px; }
.preview-active-section.layout-style-5 .preview-question-text { font-size: 1.15rem; }

/* Preview Layout 6 */
.preview-active-section.layout-style-6 { justify-content: flex-start; }
.preview-active-section.layout-style-6 .preview-choices-grid { order: 1; margin-top: 4px; margin-bottom: 8px; gap: 6px; }
.preview-active-section.layout-style-6 .preview-choice-btn { min-height: 32px; font-size: 0.95rem; border-radius: 8px; }
.preview-active-section.layout-style-6 .preview-question-card { order: 2; margin: 0 0 4px 0; padding: 8px; border-radius: 10px; }
.preview-active-section.layout-style-6 .preview-question-text { font-size: 1.15rem; }

