/* ================================================================
   JOLLY GRID - BASE STYLES
   Uses theme variables from theme-variables.css for light/dark support
   ================================================================ */

/* ========================================
   CSS RESET
   ======================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ========================================
   ROOT VARIABLES - Layout & Typography Only
   Color variables come from theme-variables.css
   ======================================== */
:root {
    /* Layout */
    --header-height: 64px;
    --max-width: 1400px;
    --content-padding: clamp(1rem, 5vw, 3rem);
    --section-spacing: clamp(4rem, 10vw, 8rem);

    /* Typography */
    --font-display: 'Quicksand', 'Nunito', sans-serif;
    --font-body: 'Nunito', sans-serif;
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --border-radius-sm: 8px;

    /* Transitions */
    --transition: all 0.3s ease;
    --transition-fast: all 0.15s ease;
    --transition-slow: all 0.5s ease;
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ========================================
   HTML & BODY
   ======================================== */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scrollbar-gutter: stable;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

/* Background mesh effect - uses theme variables */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        var(--gradient-mesh-1),
        var(--gradient-mesh-2),
        var(--gradient-mesh-3),
        var(--gradient-mesh-4),
        var(--gradient-mesh-5);
    pointer-events: none;
    z-index: -2;
    transform: translateZ(0);
}

/* Subtle grain texture */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.02;
    pointer-events: none;
    z-index: -1;
}

/* ========================================
   MAIN CONTENT AREA
   ======================================== */
.main-content {
    padding-top: var(--header-height);
    flex: 1;
    width: 100%;
    position: relative;
}

.container,
.content-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--content-padding);
    width: 100%;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-display);
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
    color: var(--text-primary);
}

.gradient-text,
h1.gradient-text,
h2.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-heading {
    font-size: clamp(2rem, 5vw, 3.5rem);
    margin-bottom: 1.5rem;
}

.section-subheading {
    color: var(--text-secondary);
    font-size: clamp(1rem, 2vw, 1.25rem);
    max-width: 600px;
}

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

a {
    color: var(--accent-purple);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-pink);
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.75rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 1rem;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    position: relative;
    overflow: hidden;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-glow-purple);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(168, 85, 247, 0.4);
    color: white;
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-strong);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    border-color: var(--accent-purple);
    background: var(--accent-purple-10);
    transform: translateY(-2px);
    color: var(--text-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--accent-purple-05);
}

.btn-success {
    background: var(--gradient-secondary);
    color: white;
    box-shadow: var(--shadow-glow-cyan);
}

.btn-warning {
    background: var(--gradient-warm);
    color: white;
}

.btn-danger {
    background: var(--accent-red);
    color: white;
}

.btn-danger:hover {
    filter: brightness(1.1);
    color: white;
}

.btn-outline-primary {
    background: transparent;
    border: 2px solid var(--accent-purple);
    color: var(--accent-purple);
}

.btn-outline-primary:hover {
    background: var(--accent-purple);
    color: white;
}

.btn-outline-secondary {
    background: transparent;
    border: 2px solid var(--border-strong);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

/* ========================================
   CARDS
   ======================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    backdrop-filter: blur(20px);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.card:hover {
    transform: translateY(-5px);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-lg);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.5rem;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    background: transparent;
    border-top: 1px solid var(--border-light);
    padding: 1rem 1.5rem;
}

/* ========================================
   FORMS
   ======================================== */
input,
textarea,
select {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    padding: 0.875rem 1rem;
    border-radius: var(--border-radius-sm);
    width: 100%;
    transition: var(--transition);
    font-family: var(--font-body);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 3px var(--accent-purple-15);
    background: var(--input-bg);
    color: var(--text-primary);
}

.form-control {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    padding: 0.875rem 1rem;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 3px var(--accent-purple-15);
    outline: none;
    background: var(--input-bg);
    color: var(--text-primary);
}

.form-label {
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-select {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
}

.form-select:focus {
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 3px var(--accent-purple-15);
    background-color: var(--input-bg);
    color: var(--text-primary);
}

.form-check-input {
    background-color: var(--input-bg);
    border-color: var(--input-border);
}

.form-check-input:checked {
    background-color: var(--accent-purple);
    border-color: var(--accent-purple);
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px var(--accent-purple-15);
    border-color: var(--accent-purple);
}

.form-check-label {
    color: var(--text-secondary);
}

/* ========================================
   BADGES
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary,
.bg-primary {
    background: var(--accent-purple-20) !important;
    color: var(--accent-purple) !important;
    border: 1px solid var(--accent-purple-20);
}

.badge-success,
.bg-success {
    background: var(--success-bg) !important;
    color: var(--success-text) !important;
    border: 1px solid var(--success-border);
}

.badge-warning,
.bg-warning {
    background: var(--warning-bg) !important;
    color: var(--warning-text) !important;
    border: 1px solid var(--warning-border);
}

.badge-danger,
.bg-danger {
    background: var(--error-bg) !important;
    color: var(--error-text) !important;
    border: 1px solid var(--error-border);
}

.badge-info,
.bg-info {
    background: var(--info-bg) !important;
    color: var(--info-text) !important;
    border: 1px solid var(--info-border);
}

.badge-secondary,
.bg-secondary {
    background: var(--bg-tertiary) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-light);
}

/* ========================================
   ALERTS / MESSAGES
   ======================================== */
.messages-container {
    position: fixed;
    top: calc(var(--header-height) + 1rem);
    right: 1rem;
    z-index: 1000;
    max-width: 400px;
}

.message,
.alert {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-left: 4px solid var(--accent-purple);
    border-radius: var(--border-radius-sm);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s var(--ease-out-expo);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    color: var(--text-primary);
}

.message.success,
.alert-success {
    border-left-color: var(--accent-green);
    background: var(--success-bg);
}

.message.error,
.alert-danger {
    border-left-color: var(--accent-red);
    background: var(--error-bg);
}

.message.warning,
.alert-warning {
    border-left-color: var(--accent-orange);
    background: var(--warning-bg);
}

.message.info,
.alert-info {
    border-left-color: var(--accent-cyan);
    background: var(--info-bg);
}

.message-close,
.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    transition: var(--transition);
    opacity: 0.7;
}

.message-close:hover,
.btn-close:hover {
    color: var(--text-primary);
    opacity: 1;
}

/* ========================================
   NAVIGATION
   ======================================== */
.nav-link {
    position: relative;
    transition: color 0.3s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--gradient-primary);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.nav-tabs {
    border-bottom: 1px solid var(--border-light);
}

.nav-tabs .nav-link {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 1rem 1.5rem;
}

.nav-tabs .nav-link:hover {
    color: var(--text-primary);
    border-color: transparent;
}

.nav-tabs .nav-link.active {
    background: transparent;
    color: var(--accent-purple);
    border: none;
    border-bottom: 2px solid var(--accent-purple);
}

.nav-pills .nav-link {
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--border-radius-sm);
}

.nav-pills .nav-link:hover {
    background: var(--accent-purple-10);
    color: var(--text-primary);
}

.nav-pills .nav-link.active {
    background: var(--gradient-primary);
    color: white;
}

/* ========================================
   LOADING STATES
   ======================================== */
.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent-purple);
    border-right-color: var(--accent-pink);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-border {
    border-color: var(--accent-purple-20);
    border-right-color: var(--accent-purple);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   GRID LAYOUTS
   ======================================== */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.text-purple {
    color: var(--accent-purple) !important;
}

.text-pink {
    color: var(--accent-pink) !important;
}

.text-cyan {
    color: var(--accent-cyan) !important;
}

.text-green {
    color: var(--accent-green) !important;
}

.text-orange {
    color: var(--accent-orange) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-primary {
    color: var(--text-primary) !important;
}

.text-white {
    color: white !important;
}

.bg-glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
}

.bg-dark {
    background: var(--bg-tertiary) !important;
}

.glow-purple {
    box-shadow: var(--shadow-glow-purple);
}

.glow-pink {
    box-shadow: var(--shadow-glow-pink);
}

.glow-cyan {
    box-shadow: var(--shadow-glow-cyan);
}

/* ========================================
   SCROLLBAR
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 1200px) {
    .grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    :root {
        --section-spacing: 3rem;
    }

    .grid-3,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding-top: var(--header-height);
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ========================================
   SECTION STYLING
   ======================================== */
.section {
    position: relative;
    padding: var(--section-spacing) 0;
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

/* ========================================
   TABLE STYLES
   ======================================== */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-light);
    --bs-table-striped-bg: var(--bg-secondary);
    --bs-table-hover-bg: var(--accent-purple-10);
    color: var(--text-primary);
}

.table thead th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
    border-bottom: 2px solid var(--accent-purple);
}

.table td,
.table th {
    border-color: var(--border-light);
    padding: 1rem;
}

.table-striped>tbody>tr:nth-of-type(odd)>* {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.table-hover>tbody>tr:hover>* {
    background: var(--accent-purple-10);
    color: var(--text-primary);
}

/* ========================================
   MODAL STYLES
   ======================================== */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-lg);
    color: var(--text-primary);
}

.modal-header {
    border-bottom: 1px solid var(--border-light);
}

.modal-title {
    color: var(--text-primary);
}

.modal-footer {
    border-top: 1px solid var(--border-light);
}

.modal-backdrop {
    background: var(--overlay-bg);
}

/* ========================================
   DROPDOWN STYLES
   ======================================== */
.dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
}

.dropdown-item {
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    transition: var(--transition);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--accent-purple-10);
    color: var(--text-primary);
}

.dropdown-item.active,
.dropdown-item:active {
    background: var(--gradient-primary);
    color: white;
}

.dropdown-divider {
    border-color: var(--border-light);
}

/* ========================================
   BREADCRUMB
   ======================================== */
.breadcrumb {
    background: transparent;
    padding: 1rem 0;
    margin-bottom: 1.5rem;
}

.breadcrumb-item+.breadcrumb-item::before {
    color: var(--text-muted);
}

.breadcrumb-item a {
    color: var(--accent-purple);
}

.breadcrumb-item.active {
    color: var(--text-secondary);
}

/* ========================================
   PAGINATION
   ======================================== */
.pagination {
    gap: 0.25rem;
}

.page-link {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    transition: var(--transition);
}

.page-link:hover {
    background: var(--accent-purple-20);
    border-color: var(--accent-purple);
    color: var(--text-primary);
}

.page-item.active .page-link {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
}

.page-item.disabled .page-link {
    background: var(--bg-tertiary);
    border-color: var(--border-light);
    color: var(--text-muted);
    opacity: 0.5;
}

/* ========================================
   LIST GROUP
   ======================================== */
.list-group-item {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 1rem 1.25rem;
    transition: var(--transition);
}

.list-group-item:hover {
    background: var(--accent-purple-10);
}

.list-group-item.active {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
}

.list-group-item+.list-group-item {
    border-top-width: 0;
}

.list-group-item:first-child {
    border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
}

.list-group-item:last-child {
    border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
}

/* ========================================
   ACCORDION
   ======================================== */
.accordion-item {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
}

.accordion-button {
    background: var(--bg-card);
    color: var(--text-primary);
    font-weight: 600;
}

.accordion-button:not(.collapsed) {
    background: var(--accent-purple-10);
    color: var(--accent-purple);
    box-shadow: none;
}

.accordion-button:focus {
    box-shadow: 0 0 0 3px var(--accent-purple-15);
    border-color: var(--accent-purple);
}

.accordion-body {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* ========================================
   PROGRESS BAR
   ======================================== */
.progress {
    background: var(--bg-tertiary);
    border-radius: 50px;
    height: 8px;
    overflow: hidden;
}

.progress-bar {
    background: var(--gradient-primary);
    border-radius: 50px;
    transition: width 0.6s ease;
}

.progress-bar.bg-success {
    background: var(--gradient-secondary) !important;
}

.progress-bar.bg-warning {
    background: var(--gradient-warm) !important;
}

/* ========================================
   TOOLTIP
   ======================================== */
.tooltip-inner {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius-sm);
}

/* ========================================
   POPOVER
   ======================================== */
.popover {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-sm);
}

.popover-header {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.popover-body {
    color: var(--text-secondary);
}

/* ========================================
   OFFCANVAS
   ======================================== */
.offcanvas {
    background: var(--bg-card);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.offcanvas-header {
    border-bottom: 1px solid var(--border-light);
}

.offcanvas-title {
    color: var(--text-primary);
}

/* ========================================
   SELECTION
   ======================================== */
::selection {
    background: var(--accent-purple);
    color: white;
}

::-moz-selection {
    background: var(--accent-purple);
    color: white;
}

/* ========================================
   FOCUS VISIBLE
   ======================================== */
:focus-visible {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}

/* ========================================
   HR
   ======================================== */
hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-light), transparent);
    margin: 2rem 0;
    opacity: 1;
}

/* ========================================
   CODE & PRE
   ======================================== */
code {
    background: var(--accent-purple-10);
    color: var(--accent-pink);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.875em;
}

pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    overflow-x: auto;
}

pre code {
    background: transparent;
    padding: 0;
}

/* ========================================
   BLOCKQUOTE
   ======================================== */
blockquote {
    border-left: 4px solid var(--accent-purple);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--text-secondary);
}

blockquote cite {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: normal;
}