@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
    /* ======= BRAND PALETTE ======= */
    --gold:           #dcb557;
    --gold-dark:      #c79e3d;
    --gold-light:     #f5e3b5;
    --gold-glow:      rgba(220, 181, 87, 0.22);
    --cream:          #fbf9f5;
    --cream-dark:     #f2ebe0;
    --green:          #163c2b; /* Premium rich forest/emerald green */
    --green-light:    #225c42;
    --green-dark:     #0c251a;
    --near-black:     #111827; /* Modern tailwind dark slate */

    /* ======= SEMANTIC ALIASES ======= */
    --primary:        var(--green);
    --primary-light:  var(--green-light);
    --primary-dark:   var(--green-dark);
    --accent:         var(--gold);
    --accent-light:   rgba(220, 181, 87, 0.08);

    /* ======= SURFACE COLORS ======= */
    --bg-main:        #FAF8F5;        /* Premium warm background */
    --bg-surface:     #ffffff;        /* Crisp white card background */
    --bg-warm:        #f3ece0;        /* Soft cream accent */
    --bg-offset:      #f3edd8;        /* Off-white warm tint for chips */

    /* ======= TEXT COLORS ======= */
    --text-main:      var(--near-black);
    --text-muted:     #4b5563;        /* Slate 600 */
    --text-light:     #9ca3af;        /* Slate 400 */
    --text-on-dark:   var(--cream);

    /* ======= SEMANTIC FEEDBACK ======= */
    --success:        #10b981;        /* Modern emerald */
    --success-bg:     #ecfdf5;
    --danger:         #ef4444;        /* Modern red */
    --danger-bg:      #fef2f2;
    --warning:        var(--gold);
    --info:           #3b82f6;        /* Modern blue */

    /* ======= BORDERS ======= */
    --border-color:   #e4ddd0;
    --border-hover:   var(--green);
    --border-light:   #f2ece0;

    /* ======= SHADOWS (Soft & Colored) ======= */
    --shadow-sm:      0 2px 4px 0 rgba(22, 60, 43, 0.02);
    --shadow-md:      0 4px 20px -2px rgba(22, 60, 43, 0.04), 0 2px 8px -1px rgba(22, 60, 43, 0.02);
    --shadow-lg:      0 12px 30px -4px rgba(22, 60, 43, 0.06), 0 4px 12px -2px rgba(22, 60, 43, 0.03);
    --shadow-xl:      0 24px 48px -8px rgba(22, 60, 43, 0.08), 0 8px 24px -4px rgba(22, 60, 43, 0.04);
    --shadow-colored: 0 10px 25px -5px rgba(22, 60, 43, 0.18);
    --shadow-gold:    0 8px 20px -4px rgba(220, 181, 87, 0.25);

    /* ======= SHAPE ======= */
    --radius-sm:      8px;
    --radius-md:      12px;
    --radius-lg:      18px;
    --radius-xl:      24px;
    --radius-full:    9999px;

    /* ======= TYPOGRAPHY ======= */
    --font-heading:   'Space Grotesk', sans-serif;
    --font-body:      'IBM Plex Sans Arabic', sans-serif;

    /* ======= GRADIENTS ======= */
    --primary-gradient: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
    --gold-gradient:    linear-gradient(135deg, var(--gold-dark) 0%, var(--gold) 60%, var(--gold-light) 100%);
}

body.dark {
    --bg-main:        #0a100d;
    --bg-surface:     #121d18;
    --bg-warm:        #182820;
    --bg-offset:      #080c0a;
    --text-main:      #f4f1ea;
    --text-muted:     #9bb0a5;
    --text-light:     #5b6f64;
    --border-color:   #1f3529;
    --border-light:   #15251d;
    --shadow-md:      0 4px 20px -2px rgba(0, 0, 0, 0.60);
    --shadow-lg:      0 12px 30px -4px rgba(0, 0, 0, 0.65);
    --shadow-colored: 0 10px 25px -5px rgba(220, 181, 87, 0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Custom Scrollbar for premium feel */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
    transition: background 0.3s;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

body {
    font-family: var(--font-body);
    color: var(--text-main);
    background-color: var(--bg-main);
    line-height: 1.65;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* Subtle brand-colored ambient blobs */
body::before,
body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: -1;
}

body::before {
    width: 60vw;
    height: 60vw;
    max-width: 800px;
    max-height: 800px;
    background: radial-gradient(circle, rgba(220, 181, 87, 0.08) 0%, transparent 70%);
    top: -10%;
    right: -10%;
    animation: float 25s ease-in-out infinite alternate;
}

body::after {
    width: 50vw;
    height: 50vw;
    max-width: 650px;
    max-height: 650px;
    background: radial-gradient(circle, rgba(33, 73, 55, 0.06) 0%, transparent 70%);
    bottom: -10%;
    left: -10%;
    animation: float 30s ease-in-out infinite alternate-reverse;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-body); /* Unified font, font-weight handles styling */
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: all 0.25s ease;
    font-weight: 600;
}

a:hover {
    color: var(--primary-light);
}

/* Animations Core */
.animate-fade-in {
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-slide-up {
    animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-delay-100 { animation-delay: 100ms; }
.animate-delay-200 { animation-delay: 200ms; }
.animate-delay-300 { animation-delay: 300ms; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(25px, -35px) scale(1.03); }
    100% { transform: translate(-15px, 15px) scale(0.97); }
}

/* Base Layouts */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
}

/* Cards & Surfaces */
.card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2.5rem;
    border: 1px solid var(--border-color);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--gold-light);
}

/* Buttons */
button, .btn {
    font-family: var(--font-body);
    cursor: pointer;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.75rem 1.75rem;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-colored);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(22, 60, 43, 0.25), var(--shadow-gold);
    opacity: 0.95;
}

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

.btn-secondary {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background-color: var(--bg-warm);
    border-color: var(--gold);
    color: var(--primary);
    transform: translateY(-1px);
}

.btn-danger {
    background-color: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.btn-danger:hover {
    background-color: var(--danger);
    color: white;
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.18);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: var(--bg-warm);
    color: var(--primary);
}

.btn-icon-only {
    padding: 0.6rem;
    border-radius: var(--radius-full);
    width: 42px;
    height: 42px;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

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

.form-control {
    width: 100%;
    padding: 0.85rem 1.1rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-surface);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all 0.25s ease;
}

.form-control:hover {
    border-color: var(--text-light);
}

.form-control:focus {
    outline: none;
    border-color: var(--green);
    background-color: var(--bg-surface);
    box-shadow: 0 0 0 4px rgba(33, 73, 55, 0.08);
}

.form-control::placeholder {
    color: var(--text-light);
    opacity: 0.8;
}

/* Navbar */
.navbar {
    background: rgba(250, 248, 245, 0.85); /* Frosty glass */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    padding: 1.1rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(33, 73, 55, 0.02);
}

.navbar.dark-nav {
    background: rgba(10, 16, 13, 0.85);
}

.nav-brand {
    font-size: 1.45rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--bg-surface);
    color: var(--text-main);
    padding: 1.1rem 1.75rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border-left: 5px solid var(--primary);
    transform: translateY(100px) scale(0.9);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.toast.show {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.toast.success {
    border-left-color: var(--success);
    background: var(--success-bg);
}

.toast.error {
    border-left-color: var(--danger);
    background: var(--danger-bg);
}

/* Loaders */
.loader {
    border: 3px solid rgba(33, 73, 55, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Custom Builder / Workspace additions */
.workspace {
    display: flex;
    min-height: calc(100vh - 70px);
    background-color: var(--bg-main);
}

.sidebar {
    width: 320px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    height: calc(100vh - 70px);
    position: sticky;
    top: 70px;
    overflow-y: auto;
}

.builder-canvas {
    flex: 1;
    padding: 3rem;
    max-width: 800px;
    margin: 0 auto;
}

/* Form Builder Questions */
.question-block {
    position: relative;
    padding-left: 3rem;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.question-block:hover,
.question-block.active {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.question-block.active {
    box-shadow: 0 0 0 2px var(--primary-light);
}

.drag-handle {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: grab;
    color: var(--text-light);
    font-size: 1.25rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: color 0.2s, background 0.2s;
}

.drag-handle:hover {
    color: var(--text-main);
    background: var(--bg-offset);
}

.drag-handle:active {
    cursor: grabbing;
}

.options-container .option-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

/* Utility layout */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }

/* ============ STAR RATING ============ */
.star-rating-container {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 0.3rem;
    margin-top: 1.25rem;
}
.star-label {
    cursor: pointer;
    color: var(--border-color);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.star-rating-container input:checked ~ .star-label,
.star-label:hover,
.star-label:hover ~ .star-label {
    color: var(--gold);
    transform: scale(1.15);
}
.star-label svg {
    fill: currentColor;
    filter: drop-shadow(0 2px 6px rgba(220,181,87,0.15));
}

/* ============ LINEAR SCALE ============ */
.linear-scale-container input:checked ~ .scale-radio {
    background-color: var(--primary);
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 5px rgba(33, 73, 55, 0.12);
    transform: scale(1.2);
}
.scale-item:hover .scale-radio {
    border-color: var(--primary);
    transform: scale(1.08);
}
.scale-radio {
    background: transparent;
}

/* ============ GRID TABLE ============ */
.grid-mark.checked {
    border-color: var(--green) !important;
    background: var(--green) !important;
}
.grid-mark.checked::after {
    opacity: 1 !important;
    transform: scale(1) !important;
}
.grid-row:hover {
    background: rgba(33, 73, 55, 0.03) !important;
}
.grid-cell-label:has(input:checked) .grid-mark {
    border-color: var(--green) !important;
    background: var(--green) !important;
}
.grid-cell-label:has(input:checked) .grid-mark::after {
    opacity: 1 !important;
    transform: scale(1) !important;
}

.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.p-6 { padding: 1.5rem; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* Badges */
.badge {
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: inline-flex;
    align-items: center;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-primary {
    background: rgba(33, 73, 55, 0.06);
    color: var(--primary);
}

/* ============ MOBILE RESPONSIVENESS ============ */
@media (max-width: 768px) {
    .navbar {
        padding: 1rem 1.5rem;
    }

    /* --- Responses Page (responses.html) --- */
    .builder-nav {
        flex-direction: column;
        padding: 1rem 1.5rem;
        gap: 1rem;
        text-align: center;
    }
    
    .tabs {
        gap: 1.25rem;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .stat-card {
        max-width: 100%;
    }
    
    .table-container th, 
    .table-container td {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }
    
    .grid-answer {
        min-width: 180px;
    }
    
    .grid-row-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .grid-badge {
        align-self: flex-start;
    }

    /* --- Form Grids (form.html) - Scaled Original Pattern --- */
    .grid-table-container {
        border-radius: 8px !important;
        margin-left: -1rem;
        margin-right: -1rem;
        width: calc(100% + 2rem);
        border-left: none !important;
        border-right: none !important;
    }
    
    .grid-table-container th {
        font-size: 0.75rem !important;
        padding: 0.75rem 0.5rem !important;
    }
    
    .grid-table-container td {
        padding: 0.5rem !important;
    }
    
    .grid-table-container td:first-child {
        font-size: 0.85rem !important;
        min-width: 100px !important;
    }
    
    .grid-cell-label {
        width: 32px !important;
        height: 32px !important;
    }
    
    .option-radio, .option-checkbox {
        width: 16px !important;
        height: 16px !important;
    }
}