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

:root {
    /* Primary Colors */
    --primary-dark: #111B38;
    --primary-accent: #8863CF;
    --primary-light: #FFFFFF;
    --secondary-light: #E9E9E9;
    /* Blue Gradient Scale */
    --blue-1: #eef0fa;
    --blue-2: #c3caee;
    --blue-3: #92a2e0;
    --blue-4: #607bd2;
    --blue-5: #3f58a1;
    --blue-6: #27386a;
    --blue-7: #111B38;

    /* Purple Gradient Scale */
    --purple-1: #ede9f8;
    --purple-2: #c9bdeb;
    --purple-3: #a890de;
    --purple-4: #8863CF;
    --purple-5: #663da9;
    --purple-6: #3f246d;
    --purple-7: #1d0e36;

    /* Magenta/Pink Gradient Scale */
    --magenta-1: #f7eafc;
    --magenta-2: #E4B5F6;
    --magenta-3: #d47cf0;
    --magenta-4: #be3cde;
    --magenta-5: #8929a1;
    --magenta-6: #581768;
    --magenta-7: #2b0734;

    /* Neutral Gray Scales */
    --gray-scale1-1: #FFFFFF;
    --gray-scale1-2: #d6d6d6;
    --gray-scale1-3: #afafaf;
    --gray-scale1-4: #898989;
    --gray-scale1-5: #656565;
    --gray-scale1-6: #434343;
    --gray-scale1-7: #242424;

    --gray-scale2-1: #E9E9E9;
    --gray-scale2-2: #c1c1c1;
    --gray-scale2-3: #9a9a9a;
    --gray-scale2-4: #767676;
    --gray-scale2-5: #535353;
    --gray-scale2-6: #323232;
    --gray-scale2-7: #151515;

    --gray-scale3-1: #f1f1f1;
    --gray-scale3-2: #cbcbcd;
    --gray-scale3-3: #a4a4a8;
    --gray-scale3-4: #7f7f84;
    --gray-scale3-5: #5b5b62;
    --gray-scale3-6: #3a3a3f;
    --gray-scale3-7: #1c1c1f;

    /* Semantic Color Aliases */
    --primary: var(--primary-accent);
    --primary-hover: var(--purple-5);
    --primary-light: var(--purple-1);
    --secondary: var(--secondary-accent);
    --dark: var(--primary-dark);
    --gray-light: var(--gray-scale3-1);
    --gray: var(--gray-scale1-4);
    --white: var(--primary-light);

    /* Shadows and Effects */
    --shadow-sm: 0 1px 2px 0 rgba(17, 27, 56, 0.05);
    --shadow: 0 4px 6px -1px rgba(17, 27, 56, 0.1), 0 2px 4px -1px rgba(17, 27, 56, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(17, 27, 56, 0.1), 0 4px 6px -2px rgba(17, 27, 56, 0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

/* Font Faces */
@font-face {
    font-family: 'PP Neue Montreal';
    src: url('../fonts/PP Neue Montreal - Medium v2.6/PPNeueMontreal-Medium.woff2') format('woff2'),
        url('../fonts/PP Neue Montreal - Medium v2.6/PPNeueMontreal-Medium.woff') format('woff'),
        url('../fonts/PP Neue Montreal - Medium v2.6/PPNeueMontreal-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'PT Serif';
    src: url('../fonts/PT_Serif/PTSerif-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'PT Serif';
    src: url('../fonts/PT_Serif/PTSerif-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

body {
    font-family: 'PP Neue Montreal', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    background: linear-gradient(135deg, #faf8ff 0%, #f0e6ff 50%, #e8d5ff 100%);
    /* New global gradient */
    background-attachment: fixed;
    /* Ensure gradient stays during scroll */
    color: var(--dark);
    min-height: 100vh;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'PT Serif', serif;
    font-weight: 700;
    line-height: 1.2;
    color: var(--dark);
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.75rem;
}

h4 {
    font-size: 1.5rem;
}

h5 {
    font-size: 1.25rem;
}

h6 {
    font-size: 1rem;
}

/* Buttons use PP Neue Montreal for modern look */
button,
.btn,
input[type="submit"],
input[type="button"] {
    font-family: 'PP Neue Montreal', sans-serif;
    font-weight: 500;
}

/* Form elements use PP Neue Montreal for consistency */
input,
textarea,
select {
    font-family: 'PP Neue Montreal', sans-serif;
}

/* Special accent text can use PT Serif */
.serif-accent {
    font-family: 'PT Serif', serif;
}

.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: transparent;
}

/* Navigation */
.navbar {
    background: transparent;
    backdrop-filter: none;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--primary-dark);
    /* box-shadow removed for cleaner look */
    width: 100%;
    min-height: 70px;
    transition: all 0.3s ease;
    position: relative;
    z-index: 10;
}

.nav-brand {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1;
}

.nav-brand img {
    height: 40px;
    width: auto;
    object-fit: contain;
    transition: var(--transition);
}

.nav-brand a:hover img {
    transform: scale(1.05);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    position: relative;
    z-index: 1;
}

.nav-links a {
    color: var(--gray-scale1-5);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-links a:hover {
    color: var(--primary-dark);
    background: rgba(136, 99, 207, 0.1);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.nav-links a:active {
    transform: translateY(0);
}

.user-info {
    background: rgba(136, 99, 207, 0.1);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    color: var(--primary-dark);
    border: 1px solid rgba(136, 99, 207, 0.2);
}

.credits-badge {
    background: var(--primary-accent);
    color: var(--white);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.credits-badge::before {
    content: '✨';
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    /* Chatbox Styles */
    .chatbox-container {
        grid-area: chatbox;
        background: white;
        border-left: 1px solid #e2e8f0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        position: relative;
        z-index: 50;
        height: 100%;
        /* Fix: Fill grid area, don't force viewport height */
        min-height: 0;
        /* Fix: Allow flex children to scroll */
        padding-top: 0;
    }

    .chatbox-header {
        padding: 1rem 1.5rem;
        /* border-bottom: 1px solid #f0f0f0; */
        /* Removed for seamless look */
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: white;
        /* Ensure header doesn't get cut off */
        flex-shrink: 0;
    }

    /* Modal Backdrop - Force Fixed Position */
    .modal-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 10000;
        /* Highest priority */
        backdrop-filter: blur(2px);
    }

    .sidebar-resizer {
        position: absolute;
        top: 0;
        bottom: 0;
        left: -8px;
        /* Changed from right to left - on left edge of chatbox */
        width: 16px;
        background: transparent;
        cursor: col-resize;
        z-index: 10000;
        transition: background 0.2s;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    /* Always visible grip handle */
    .sidebar-resizer::after {
        content: '⋮⋮';
        font-size: 12px;
        letter-spacing: -4px;
        color: rgba(136, 99, 207, 0.5);
        background: #f0edf7;
        width: 10px;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 4px;
        transition: all 0.2s ease;
        border: 1px solid rgba(136, 99, 207, 0.2);
    }

    .sidebar-resizer:hover::after,
    .sidebar-resizer.resizing::after {
        background: var(--primary-accent);
        color: white;
        width: 12px;
        height: 56px;
        /* visual feedback */
    }

    /* Collapsed State - Hide Chat */
    body.sidebar-collapsed .container {
        grid-template-columns: 1fr 0px;
        /* Remove chatbox column space */
    }

    body.sidebar-collapsed .chatbox-container {
        display: none;
    }

    body.sidebar-collapsed .sidebar-resizer {
        display: none;
    }

    /* Floating Expand Button */
    .sidebar-expand-btn {
        position: fixed;
        bottom: 30px;
        right: 30px;
        width: 150px;
        padding: 0;
        height: 150px;
        background: var(--primary-accent);
        color: white;
        border-radius: 50%;
        display: none;
        align-items: center;
        justify-content: center;
        gap: 8px;
        /* Reduced gap */
        flex-direction: column;
        /* Stack logo above icon */
        box-shadow: 0 8px 24px rgba(136, 99, 207, 0.6);
        font-size: 1.2rem;
        z-index: 1000;
        cursor: pointer;
        transition: all 0.2s ease;
    }


    body.sidebar-collapsed .sidebar-expand-btn {
        display: flex;
        animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    .sidebar-expand-btn:hover {
        transform: scale(1.1);
        background: var(--purple-5);
    }

    @keyframes popIn {
        from {
            transform: scale(0);
            opacity: 0;
        }

        to {
            transform: scale(1);
            opacity: 1;
        }
    }

    .nav-links {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .nav-links a {
        width: 100%;
        text-align: center;
    }

    .user-info {
        flex-direction: column;
        width: 100%;
        text-align: center;
    }
}

/* Collapsed State - Hide Chat (works on all screen sizes) */
body.sidebar-collapsed .container {
    grid-template-columns: 1fr 0px;
}

body.sidebar-collapsed .chatbox-container {
    display: none;
}

body.sidebar-collapsed .sidebar-resizer {
    display: none;
}

/* Floating Expand Button */
.sidebar-expand-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: var(--primary-accent);
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(136, 99, 207, 0.4);
    cursor: pointer;
    z-index: 1000;
    transition: all 0.2s ease;
    border: none;
}

body.sidebar-collapsed .sidebar-expand-btn {
    display: flex;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.sidebar-expand-btn:hover {
    transform: scale(1.1);
    background: var(--purple-5);
}

@keyframes popIn {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Main content */
.content {
    flex: 1;
    padding: 3rem 2rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    position: relative;
}

/* Top line removed for cleaner look */

/* Forms */
.form-container {
    background-color: var(--white);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(17, 27, 56, 0.08);
    margin: 0 auto;
    border: 1px solid rgba(136, 99, 207, 0.1);
    max-width: 900px;
    width: 100%;
    backdrop-filter: blur(10px);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--dark);
}

.form-group input {
    width: 100%;
    padding: 0.85rem;
    border: 1px solid rgba(136, 99, 207, 0.2);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.8);
}

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

.btn {
    background-color: var(--primary);
    color: var(--white);
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
    text-align: center;
    display: inline-block;
}

.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Footer */
.footer {
    background-color: var(--dark);
    color: var(--gray);
    padding: 1.5rem;
    margin-top: auto;
    font-size: 0.9rem;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--gray);
    text-decoration: none;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--white);
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* Alert messages */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-error {
    background-color: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.alert-success {
    background-color: #dcfce7;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.activity-topic {
    font-weight: 600;
    color: var(--primary-hover);
    margin-bottom: 0.25rem;
}

/* Payment page styles */
.packages-container {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: nowrap;
}

.credits-package {
    background: var(--white);
    border-radius: var(--radius);
    padding: 0.75rem;
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    flex: 1;
    min-width: 180px;
    max-width: 220px;
}

.credits-package:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.credits-package.featured {
    border: 2px solid var(--primary);
    transform: scale(1.02);
    background: linear-gradient(135deg, var(--white) 0%, var(--purple-1) 100%);
}

.credits-package.featured:hover {
    transform: scale(1.02) translateY(-3px);
}

.package-header {
    margin-bottom: 0.5rem;
    position: relative;
}

.package-header h3 {
    color: var(--dark);
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.price {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.2rem;
}

.package-description {
    color: var(--gray);
    margin-bottom: 0.5rem;
    line-height: 1.3;
    font-size: 0.85rem;
}

.credits-value {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-bottom: 0.5rem;
}

.credits-value span {
    font-weight: 600;
}

.credits-package .btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .packages-container {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        flex-wrap: wrap;
    }

    .credits-package {
        width: 100%;
        max-width: 280px;
    }

    .form-container {
        padding: 1rem;
    }
}