/* ==========================================================================
   Akademiku – Global Design System
   ========================================================================== */

:root {
    --color-primary:        #4f46e5;
    --color-primary-soft:   #818cf8;
    --color-secondary:      #06b6d4;
    --color-accent:         #f59e0b;
    --color-success:        #10b981;
    --color-danger:         #ef4444;
    --color-warning:        #f59e0b;
    --color-info:           #3b82f6;

    --bg-app:        #f4f6fb;
    --bg-card:       #ffffff;
    --bg-soft:       #f9fafb;
    --bg-dark:       #0f172a;

    --text-primary:  #1f2937;
    --text-secondary:#6b7280;
    --text-muted:    #9ca3af;

    --border:        #e5e7eb;
    --border-strong: #d1d5db;

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow:    0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.08);

    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);

    --gradient-primary: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
    --gradient-hero:    linear-gradient(135deg, #1e1b4b 0%, #4f46e5 50%, #06b6d4 100%);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text-primary);
    background: var(--bg-app);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-primary-soft); }

h1, h2, h3, h4, h5 { margin: 0 0 .5em; color: var(--text-primary); font-weight: 700; }

img { max-width: 100%; display: block; }

/* ==========================================================================
   Layout primitives
   ========================================================================== */

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.app-shell {
    display: flex;
    min-height: calc(100vh - 60px);
}

.app-sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
}

.app-main {
    flex: 1;
    padding: 28px;
    min-width: 0;
}

@media (max-width: 900px) {
    .app-sidebar { display: none; }
}

/* ==========================================================================
   Header
   ========================================================================== */

.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

.app-header__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.brand img { width: 32px; height: 32px; }

.nav-primary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.nav-primary a {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all var(--transition);
}

.nav-primary a:hover,
.nav-primary a.active {
    background: var(--bg-soft);
    color: var(--color-primary);
}

/* ==========================================================================
   Sidebar navigation (admin / app shell)
   ========================================================================== */

.side-nav { list-style: none; padding: 0; margin: 0; }

.side-nav li { margin-bottom: 4px; }

.side-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

.side-nav a:hover,
.side-nav a.active {
    background: rgba(79, 70, 229, 0.08);
    color: var(--color-primary);
}

.side-nav .nav-section-title {
    text-transform: uppercase;
    letter-spacing: .05em;
    font-size: .75rem;
    color: var(--text-muted);
    padding: 12px 14px 6px;
    font-weight: 700;
}

/* ==========================================================================
   Cards / panels
   ========================================================================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.card-title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.card-subtitle { color: var(--text-secondary); margin: 4px 0 0; font-size: .9rem; }

.panel-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-card .label {
    color: var(--text-secondary);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
}

.stat-card .value {
    font-size: 1.8rem;
    font-weight: 700;
}

.stat-card .delta {
    font-size: .85rem;
    color: var(--color-success);
}

.stat-card .icon-circle {
    align-self: flex-end;
    background: rgba(79, 70, 229, .12);
    color: var(--color-primary);
    width: 38px;
    height: 38px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
}

/* ==========================================================================
   Buttons / forms
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
    font-size: .92rem;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(79, 70, 229, .25); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn--secondary { background: var(--bg-soft); color: var(--text-primary); border-color: var(--border); }
.btn--secondary:hover { background: #eef2f7; box-shadow: none; }

.btn--ghost { background: transparent; color: var(--color-primary); }
.btn--ghost:hover { background: rgba(79, 70, 229, .08); box-shadow: none; }

.btn--danger { background: var(--color-danger); }
.btn--danger:hover { background: #dc2626; box-shadow: 0 8px 18px rgba(239, 68, 68, .3); }

.btn--success { background: var(--color-success); }
.btn--success:hover { box-shadow: 0 8px 18px rgba(16, 185, 129, .3); }

.btn--sm { padding: 6px 12px; font-size: .82rem; }
.btn--lg { padding: 14px 24px; font-size: 1rem; }
.btn--block { display: flex; width: 100%; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .9rem; }

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="number"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .95rem;
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

.form-control:focus,
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

textarea { min-height: 100px; resize: vertical; }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}

.table th {
    background: var(--bg-soft);
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .05em;
    font-weight: 700;
}

.table tbody tr:hover { background: rgba(79, 70, 229, .04); }

/* ==========================================================================
   Badges / tags
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    background: rgba(79, 70, 229, .12);
    color: var(--color-primary);
}

.badge--success { background: rgba(16, 185, 129, .15); color: var(--color-success); }
.badge--warning { background: rgba(245, 158, 11, .15); color: var(--color-warning); }
.badge--danger  { background: rgba(239, 68, 68, .15);  color: var(--color-danger); }
.badge--info    { background: rgba(59, 130, 246, .15); color: var(--color-info); }
.badge--muted   { background: #e5e7eb; color: var(--text-secondary); }

/* ==========================================================================
   Alerts / toasts
   ========================================================================== */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--color-primary);
    background: rgba(79, 70, 229, .08);
    margin-bottom: 16px;
    font-size: .9rem;
}

.alert--success { border-color: var(--color-success); background: rgba(16, 185, 129, .08); }
.alert--warning { border-color: var(--color-warning); background: rgba(245, 158, 11, .08); }
.alert--danger  { border-color: var(--color-danger);  background: rgba(239, 68, 68, .08); }

/* ==========================================================================
   Course / thumbnail grid (e-course panel)
   ========================================================================== */

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 22px;
}

.course-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
    display: flex;
    flex-direction: column;
}

.course-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.course-card__cover {
    aspect-ratio: 16 / 9;
    background: var(--gradient-primary);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 1.4rem;
    text-align: center;
    padding: 12px;
}

.course-card__cover img {
    width: 100%; height: 100%; object-fit: cover;
}

.course-card__body { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.course-card__title { font-weight: 700; font-size: 1rem; }
.course-card__desc { color: var(--text-secondary); font-size: .85rem; }
.course-card__meta { display: flex; justify-content: space-between; font-size: .8rem; color: var(--text-muted); margin-top: auto; }

/* ==========================================================================
   Hero section
   ========================================================================== */

.hero {
    background: var(--gradient-hero);
    color: #fff;
    border-radius: var(--radius-xl);
    padding: 48px;
    margin-bottom: 32px;
    position: relative;
    overflow: hidden;
}

.hero h1 { font-size: 2.2rem; margin: 0 0 12px; color: #fff; }
.hero p  { max-width: 600px; opacity: .9; }

.hero::after {
    content: "";
    position: absolute;
    width: 240px; height: 240px;
    border-radius: 50%;
    background: rgba(255,255,255,.06);
    right: -60px; top: -60px;
}

/* ==========================================================================
   Communication panel (end-to-end channels)
   ========================================================================== */

.comm-wrapper {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    min-height: 600px;
}

@media (max-width: 800px) {
    .comm-wrapper { grid-template-columns: 1fr; }
}

.channel-list {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 12px;
    overflow-y: auto;
}

.channel-list__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}

.channel-list__title {
    font-weight: 700;
    font-size: .9rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: .05em;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    font-size: .9rem;
    color: var(--text-primary);
}

.channel-item:hover { background: var(--bg-soft); }
.channel-item.active { background: rgba(79, 70, 229, .12); color: var(--color-primary); font-weight: 600; }

.channel-item .presence {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--color-success);
}

.channel-item .presence.offline { background: var(--text-muted); }

.channel-item .channel-name { flex: 1; }
.channel-item .unread {
    background: var(--color-primary);
    color: #fff;
    font-size: .7rem;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 700;
}

/* Chat panel */

.chat-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header__title { font-weight: 700; }
.chat-header__meta  { font-size: .8rem; color: var(--text-secondary); }

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-soft);
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 540px;
}

.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: #fff;
    border: 1px solid var(--border);
    font-size: .9rem;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
}

.message.from-me {
    align-self: flex-end;
    background: var(--gradient-primary);
    color: #fff;
    border-color: transparent;
}

.message .meta {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: 6px;
    display: block;
}

.message.from-me .meta { color: rgba(255,255,255,.8); }

.chat-footer {
    padding: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-footer textarea {
    min-height: 44px;
    max-height: 140px;
    resize: none;
}

/* ==========================================================================
   Modal / toast
   ========================================================================== */

.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .55);
    display: none;
    align-items: center; justify-content: center;
    z-index: 100;
}

.modal-backdrop.open { display: flex; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 480px;
    width: calc(100% - 32px);
    box-shadow: var(--shadow-lg);
}

.modal h3 { margin-top: 0; }

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
    background: var(--bg-dark);
    color: rgba(255,255,255,.75);
    padding: 28px 20px;
    margin-top: 40px;
    text-align: center;
    font-size: .85rem;
}

/* ==========================================================================
   Utility
   ========================================================================== */

.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success   { color: var(--color-success); }
.text-danger    { color: var(--color-danger); }
.text-center    { text-align: center; }
.text-right     { text-align: right; }

.d-flex      { display: flex; }
.d-grid      { display: grid; }
.gap-1       { gap: 4px; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.gap-4       { gap: 20px; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1      { flex: 1; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 20px; }

.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 20px; }

.hidden { display: none !important; }
