/* Modern SaaS Dashboard Stylesheet
   Student Productivity SaaS Platform
   Replaces the older SB Admin-style theme with a modern, clean, responsive UI.
*/

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;

    --secondary-color: #64748b;
    --success-color: #10b981;
    --info-color: #06b6d4;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;

    --dark-color: #0f172a;
    --muted-color: #94a3b8;
    --body-bg: #f4f7fb;
    --card-bg: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --border-color: #e2e8f0;

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;

    --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.10);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.14);

    --sidebar-width: 280px;
    --transition: all 0.25s ease;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: Inter, "Nunito", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(99, 102, 241, 0.10), transparent 35%),
        radial-gradient(circle at top right, rgba(6, 182, 212, 0.08), transparent 30%),
        var(--body-bg);
    color: #1e293b;
    min-height: 100vh;
}

a {
    color: inherit;
}

a:hover {
    text-decoration: none;
}

/* Layout */
.wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 16px;
    left: 16px;
    bottom: 16px;
    height: calc(100vh - 32px);
    z-index: 1000;
    background:
        linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.98)),
        var(--sidebar-bg);
    color: #fff;
    border-radius: var(--radius-lg);
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar.active {
    transform: translateX(calc(-1 * var(--sidebar-width) - 32px));
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 20px;
}

.sidebar .sidebar-header {
    padding: 24px 22px;
    background: transparent;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar .sidebar-header h3 {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.03em;
}

.sidebar .sidebar-header h3::before {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.16);
}

.sidebar ul.components {
    padding: 16px 12px;
    list-style: none;
}

.sidebar ul li {
    margin-bottom: 6px;
}

.sidebar ul li a {
    padding: 12px 14px;
    font-size: 0.92rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    color: rgba(226, 232, 240, 0.82);
    text-decoration: none;
    transition: var(--transition);
    border-radius: 14px;
}

.sidebar ul li a:hover {
    color: #fff;
    background: var(--sidebar-hover);
    transform: translateX(3px);
}

.sidebar ul li.active > a {
    color: #fff;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    box-shadow: 0 10px 24px rgba(99, 102, 241, 0.35);
}

.sidebar ul li a i {
    margin-right: 12px;
    width: 22px;
    text-align: center;
    font-size: 1rem;
}

.sidebar ul ul {
    padding-left: 12px;
}

.sidebar ul ul a {
    padding-left: 34px;
    font-size: 0.84rem;
    color: rgba(226, 232, 240, 0.68);
}

/* Content Area */
#content {
    width: calc(100% - var(--sidebar-width) - 32px);
    min-height: 100vh;
    transition: var(--transition);
    position: absolute;
    top: 0;
    right: 0;
    padding: 16px 24px 32px;
}

#content.active {
    width: 100%;
}

/* Navbar */
.navbar {
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.82) !important;
    border: 1px solid rgba(226, 232, 240, 0.75);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    margin-bottom: 24px;
}

.navbar .navbar-brand,
.navbar .nav-link {
    font-weight: 700;
    color: var(--dark-color) !important;
}

.navbar .btn-info,
#sidebarCollapse {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    color: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 22px rgba(99, 102, 241, 0.25);
}

/* Cards */
.card {
    border: 1px solid rgba(226, 232, 240, 0.85);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.88);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
    animation: fadeIn 0.45s ease-out;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.card-header {
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    font-weight: 800;
    color: var(--dark-color);
}

.card-body {
    padding: 20px;
}

/* Dashboard Stats */
.text-xs {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.font-weight-bold {
    font-weight: 800 !important;
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: "";
    position: absolute;
    width: 110px;
    height: 110px;
    right: -35px;
    top: -35px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.10);
}

/* Progress Bars */
.progress {
    height: 10px;
    background-color: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    border-radius: 999px;
}

/* Tables */
.table {
    margin-bottom: 0;
    color: #334155;
}

.table th {
    border-top: none;
    font-weight: 800;
    color: #475569;
    background: #f8fafc;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.table td,
.table th {
    vertical-align: middle;
    padding: 14px 16px;
    border-color: #edf2f7;
}

.table-hover tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    padding: 0.45rem 0.7rem;
    font-weight: 700;
    border-radius: 999px;
}

/* Buttons */
.btn {
    border-radius: 14px;
    font-weight: 700;
    padding: 0.62rem 1rem;
    transition: var(--transition);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    box-shadow: 0 10px 22px rgba(99, 102, 241, 0.22);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--primary-dark), #4338ca);
    box-shadow: 0 14px 30px rgba(99, 102, 241, 0.30);
}

.btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-warning {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
    color: #111827;
}

.btn-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-light {
    background: #f8fafc;
    border-color: #e2e8f0;
}

/* Forms */
.form-control,
.form-select,
.custom-select {
    border-radius: 14px;
    border: 1px solid #dbe3ef;
    padding: 0.72rem 0.9rem;
    color: #0f172a;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus,
.custom-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.13);
}

label {
    font-weight: 700;
    color: #334155;
    margin-bottom: 6px;
}

/* Modal */
.modal-content {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
}

.modal-footer {
    border-top: 1px solid var(--border-color);
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
}

.spinner-overlay.active {
    display: flex;
}

/* Chat */
.chat-container {
    height: 560px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
    background:
        radial-gradient(circle at top left, rgba(99, 102, 241, 0.07), transparent 30%),
        #f8fafc;
}

.message {
    margin-bottom: 16px;
    display: flex;
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-bubble {
    max-width: min(72%, 560px);
    padding: 12px 16px;
    border-radius: 20px;
    position: relative;
    box-shadow: var(--shadow-sm);
    line-height: 1.45;
}

.message.sent .message-bubble {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-bottom-right-radius: 6px;
}

.message.received .message-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 6px;
}

.message-time {
    font-size: 0.72rem;
    margin-top: 6px;
    opacity: 0.68;
}

/* Pomodoro Timer */
.pomodoro-timer {
    font-size: clamp(3rem, 8vw, 5.5rem);
    font-weight: 900;
    font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
    text-align: center;
    color: var(--dark-color);
    letter-spacing: -0.06em;
    padding: 20px 0;
}

/* Flashcards */
.flashcard {
    perspective: 1200px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    min-height: 320px;
    text-align: center;
    transition: transform 0.65s ease;
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    min-height: 320px;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    font-size: 1.1rem;
    font-weight: 700;
}

.flashcard-front {
    background: #ffffff;
    border: 1px solid #dbe3ef;
    color: var(--dark-color);
}

.flashcard-back {
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    color: white;
    transform: rotateY(180deg);
}

/* Utility Helpers */
.bg-primary-soft {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.rounded-modern {
    border-radius: var(--radius-lg) !important;
}

.shadow-modern {
    box-shadow: var(--shadow-md) !important;
}

.text-muted {
    color: var(--muted-color) !important;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseSoft {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.24);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
    }
}

.pulse-soft {
    animation: pulseSoft 2s infinite;
}

/* Responsive */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width) - 32px));
    }

    .sidebar.active {
        transform: translateX(0);
    }

    #content,
    #content.active {
        width: 100%;
        padding: 12px;
    }

    .navbar {
        border-radius: 18px;
    }
}

@media (max-width: 576px) {
    :root {
        --sidebar-width: 260px;
    }

    .sidebar {
        top: 10px;
        left: 10px;
        bottom: 10px;
        height: calc(100vh - 20px);
        border-radius: 20px;
    }

    .card-body {
        padding: 16px;
    }

    .table-responsive {
        border-radius: var(--radius-md);
    }

    .message-bubble {
        max-width: 88%;
    }

    .chat-container {
        height: 70vh;
    }
}

/* Dark Mode Support: add class="dark-mode" to body */
body.dark-mode {
    --body-bg: #020617;
    --card-bg: #0f172a;
    --border-color: #1e293b;
    color: #e2e8f0;
    background:
        radial-gradient(circle at top left, rgba(99, 102, 241, 0.15), transparent 35%),
        radial-gradient(circle at top right, rgba(6, 182, 212, 0.10), transparent 30%),
        #020617;
}

body.dark-mode .navbar,
body.dark-mode .card,
body.dark-mode .modal-content,
body.dark-mode .chat-container {
    background: rgba(15, 23, 42, 0.92) !important;
    border-color: #1e293b;
    color: #e2e8f0;
}

body.dark-mode .card-header,
body.dark-mode .table th {
    background: #111827;
    border-color: #1e293b;
    color: #e2e8f0;
}

body.dark-mode .table,
body.dark-mode label,
body.dark-mode .navbar .navbar-brand,
body.dark-mode .navbar .nav-link,
body.dark-mode .pomodoro-timer {
    color: #e2e8f0 !important;
}

body.dark-mode .form-control,
body.dark-mode .form-select,
body.dark-mode .custom-select {
    background: #0b1220;
    border-color: #1e293b;
    color: #e2e8f0;
}

body.dark-mode .chat-messages {
    background: #020617;
}

body.dark-mode .message.received .message-bubble,
body.dark-mode .flashcard-front {
    background: #111827;
    border-color: #1e293b;
    color: #e2e8f0;
}
