/* ==========================================================================
   Stitch Theme - Shared Design Tokens & Bootstrap Overrides
   Inspired by Google Stitch UI
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Font Imports
   -------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@100;200;300;400;500;600;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');

/* --------------------------------------------------------------------------
   2. CSS Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */
:root {
    /* Primary palette */
    --stitch-primary: #4F46E5;
    --stitch-primary-light: #E0E7FF;
    --stitch-primary-hover: #4338CA;

    /* Backgrounds */
    --stitch-bg: #f6f6f8;
    --stitch-bg-dark: #131022;

    /* Text */
    --stitch-text: #111827;
    --stitch-text-subtle: #6B7280;

    /* Borders & Cards */
    --stitch-border: #E5E7EB;
    --stitch-card-bg: #FFFFFF;

    /* Radii */
    --stitch-radius-card: 0.75rem;
    --stitch-radius-btn: 0.5rem;
    --stitch-radius-input: 0.5rem;

    /* Shadows */
    --stitch-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.1);

    /* Priority colours */
    --stitch-priority-high: #EF4444;
    --stitch-priority-medium: #F59E0B;
    --stitch-priority-low: #10B981;

    /* Subject colours */
    --stitch-subject-chemistry: #10B981;
    --stitch-subject-mathematics: #3B82F6;
    --stitch-subject-physics: #8B5CF6;
    --stitch-subject-biology: #F97316;
}

/* --------------------------------------------------------------------------
   3. Base Styles
   -------------------------------------------------------------------------- */
body {
    font-family: 'Lexend', sans-serif;
    background: var(--stitch-bg);
    color: var(--stitch-text);
}

.material-symbols-outlined {
    font-variation-settings:
        'FILL' 0,
        'wght' 400,
        'GRAD' 0,
        'opsz' 24;
}

/* --------------------------------------------------------------------------
   4. Bootstrap Overrides
   -------------------------------------------------------------------------- */

/* -- Buttons ------------------------------------------------------------ */
.btn-primary {
    background-color: var(--stitch-primary);
    border-color: var(--stitch-primary);
    border-radius: var(--stitch-radius-btn);
    border: none;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--stitch-primary-hover);
    border-color: var(--stitch-primary-hover);
}

.btn-outline-primary {
    border-color: var(--stitch-primary);
    color: var(--stitch-primary);
    border-radius: var(--stitch-radius-btn);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
    background-color: var(--stitch-primary);
    border-color: var(--stitch-primary);
    color: #fff;
}

/* -- Cards -------------------------------------------------------------- */
.card {
    border-radius: var(--stitch-radius-card);
    border: 1px solid var(--stitch-border);
    box-shadow: var(--stitch-shadow);
}

/* -- Forms -------------------------------------------------------------- */
.form-control,
.form-select {
    border-radius: var(--stitch-radius-input);
    border-color: var(--stitch-border);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--stitch-primary);
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.25);
}

/* -- Badges ------------------------------------------------------------- */
.badge {
    border-radius: 9999px;
}

/* -- Links -------------------------------------------------------------- */
a {
    color: var(--stitch-primary);
}

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

/* --------------------------------------------------------------------------
   5. Sidebar Navigation
   -------------------------------------------------------------------------- */
.stitch-sidebar {
    width: 256px;
    min-height: 100vh;
    background: var(--stitch-card-bg);
    border-right: 1px solid var(--stitch-border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem;
    flex-shrink: 0;
}

/* Sidebar user block */
.stitch-sidebar .sidebar-user {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.5rem;
}

.stitch-sidebar .sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background-size: cover;
    background-position: center;
}

.stitch-sidebar .sidebar-user-name {
    color: var(--stitch-text);
    font-size: 1rem;
    font-weight: 500;
}

.stitch-sidebar .sidebar-user-grade {
    color: var(--stitch-text-subtle);
    font-size: 0.875rem;
}

/* Sidebar navigation links */
.stitch-sidebar .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 1rem;
}

.stitch-sidebar .sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    text-decoration: none;
    color: var(--stitch-text);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.2s;
}

.stitch-sidebar .sidebar-nav a:hover {
    background: #f3f4f6;
}

.stitch-sidebar .sidebar-nav a.active {
    background: var(--stitch-primary-light);
    color: var(--stitch-primary);
}

.stitch-sidebar .sidebar-nav a.active .material-symbols-outlined {
    color: var(--stitch-primary);
}

.stitch-sidebar .sidebar-nav a .material-symbols-outlined {
    color: var(--stitch-text);
    font-size: 20px;
}

/* Sidebar bottom links (settings, logout, etc.) */
.stitch-sidebar .sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stitch-sidebar .sidebar-bottom a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    text-decoration: none;
    color: var(--stitch-text);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.2s;
}

.stitch-sidebar .sidebar-bottom a:hover {
    background: #f3f4f6;
}

.stitch-sidebar .sidebar-bottom a.active {
    background: var(--stitch-primary-light);
    color: var(--stitch-primary);
}

.stitch-sidebar .sidebar-bottom a.active .material-symbols-outlined {
    color: var(--stitch-primary);
}

.stitch-sidebar .sidebar-bottom a .material-symbols-outlined {
    color: var(--stitch-text);
    font-size: 20px;
}

/* --------------------------------------------------------------------------
   6. Layout Wrapper
   -------------------------------------------------------------------------- */
.stitch-layout {
    display: flex;
    min-height: 100vh;
}

.stitch-main {
    flex: 1;
    padding: 1.25rem 1.5rem;
    max-width: 100%;
    overflow-x: hidden;
}

/* --------------------------------------------------------------------------
   7. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
    .stitch-sidebar {
        display: none;
        position: fixed;
        z-index: 1050;
        height: 100vh;
    }

    .stitch-sidebar.show {
        display: flex;
    }

    .stitch-main {
        padding: 1rem;
    }
}

/* --------------------------------------------------------------------------
   8. Utility Classes
   -------------------------------------------------------------------------- */

/* Text colours */
.text-stitch-primary {
    color: var(--stitch-primary);
}

.text-stitch-subtle {
    color: var(--stitch-text-subtle);
}

/* Background colours */
.bg-stitch-primary-light {
    background: var(--stitch-primary-light);
}

/* Stitch card (standalone utility) */
.stitch-card {
    background: var(--stitch-card-bg);
    border: 1px solid var(--stitch-border);
    border-radius: var(--stitch-radius-card);
    box-shadow: var(--stitch-shadow);
    padding: 1rem;
}

/* Stat card for dashboard */
.stitch-stat-card {
    background: var(--stitch-card-bg);
    border: 1px solid var(--stitch-border);
    border-radius: var(--stitch-radius-card);
    box-shadow: var(--stitch-shadow);
    padding: 0.875rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Chip / tag */
.stitch-chip {
    display: inline-flex;
    align-items: center;
    background: var(--stitch-primary-light);
    color: var(--stitch-primary);
    border-radius: 9999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Progress bar */
.stitch-progress-bar {
    border-radius: 9999px;
    height: 0.5rem;
    background: var(--stitch-border);
    overflow: hidden;
}

.stitch-progress-bar .bar {
    height: 100%;
    border-radius: 9999px;
    background: var(--stitch-primary);
    transition: width 0.3s ease;
}

/* Floating action button */
.stitch-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1040;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--stitch-primary);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}

.stitch-fab:hover {
    background: var(--stitch-primary-hover);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.5);
}

/* Priority badges */
.priority-high {
    background: var(--stitch-priority-high);
    color: #fff;
}

.priority-medium {
    background: var(--stitch-priority-medium);
    color: #fff;
}

.priority-low {
    background: var(--stitch-priority-low);
    color: #fff;
}

/* --------------------------------------------------------------------------
   9. Mobile Hamburger Toggle Button
   -------------------------------------------------------------------------- */
.stitch-sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1051;
    width: 40px;
    height: 40px;
    border-radius: var(--stitch-radius-btn);
    background: var(--stitch-card-bg);
    border: 1px solid var(--stitch-border);
    box-shadow: var(--stitch-shadow);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--stitch-text);
}

@media (max-width: 991px) {
    .stitch-sidebar-toggle {
        display: flex;
    }
}
