/* =========================================================
   NATIVE-STYLE UI
   ========================================================= */

* {
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;

    --background: #f6f7fb;
    --surface: #ffffff;
    --surface-soft: #f9fafb;

    --text: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --border: #e5e7eb;

    --danger: #dc2626;
    --danger-bg: #fef2f2;

    --success: #15803d;
    --success-bg: #f0fdf4;

    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 18px;

    --shadow-sm:
        0 1px 3px rgba(0, 0, 0, .06),
        0 1px 2px rgba(0, 0, 0, .04);

    --shadow:
        0 8px 25px rgba(15, 23, 42, .08);

    --transition: .2s ease;
}


/* =========================================================
   BODY
   ========================================================= */

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    font-size: 15px;
    line-height: 1.5;

    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;

    user-select: none;
}


/* Allow text selection where users actually need it */

input,
textarea,
select,
p,
.lesson,
.card {
    user-select: text;
}


/* =========================================================
   LINKS
   ========================================================= */

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

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


/* =========================================================
   HEADER
   ========================================================= */

header {
    width: 100%;
    
    
    background:
        linear-gradient(
            135deg,
            #2563eb,
            #4f46e5
        );

    color: white;

    padding: 14px 0;

    position: sticky;
    top: 0;
    z-index: 100;

    box-shadow:
        0 4px 18px rgba(37, 99, 235, .50);
}

header a {
    color: white;
    text-decoration: none;
    cursor: pointer;
}

header a:hover {
    color: white;
}


/* =========================================================
   CONTAINER
   ========================================================= */

.container {
    width: min(92%, 1100px);
    margin: auto;
}


/* =========================================================
   NAVIGATION
   ========================================================= */

.nav {
    min-height: 48px;

    display: flex;
    justify-content: space-between;
    align-items: center;

    gap: 15px;
}

.nav a {
    min-height: 44px;

    display: inline-flex;
    align-items: center;

    padding: 8px 12px;

    border-radius: 10px;

    transition:
        background var(--transition),
        transform var(--transition);
}

.nav a:hover {
    background: rgba(255, 255, 255, .12);
}

.nav a:active {
    transform: scale(.97);
}


/* =========================================================
   MAIN
   ========================================================= */

main {
    padding: 32px 0 50px;
}


/* =========================================================
   CENTER
   ========================================================= */

.center {
    text-align: center;

    padding:
        clamp(50px, 12vh, 110px)
        15px;
}


/* =========================================================
   FORMS
   ========================================================= */

.form {
    width: 100%;
    max-width: 530px;
}

.form label {
    display: block;

    margin-top: 18px;
    margin-bottom: 7px;

    font-size: 14px;
    font-weight: 600;

    color: #374151;
}


/* =========================================================
   INPUTS
   ========================================================= */

input,
textarea,
select {
    width: 100%;

    min-height: 46px;

    padding: 11px 13px;

    border: 1px solid var(--border);
    border-radius: var(--radius-sm);

    outline: none;

    background: var(--surface);
    color: var(--text);

    font: inherit;

    box-shadow: var(--shadow-sm);

    transition:
        border-color var(--transition),
        box-shadow var(--transition),
        background var(--transition);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input:hover,
textarea:hover,
select:hover {
    border-color: #cbd5e1;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);

    box-shadow:
        0 0 0 3px rgba(37, 99, 235, .12);
}


/* =========================================================
   BUTTONS
   ========================================================= */

button,
.button {
    appearance: none;

    display: inline-flex;

    align-items: center;
    justify-content: center;

    min-height: 44px;

    padding: 10px 17px;

    margin-top: 15px;

    border: none;
    border-radius: var(--radius-sm);

    background:
        linear-gradient(
            135deg,
            var(--primary),
            #4f46e5
        );

    color: white;

    font: inherit;
    font-weight: 600;

    text-decoration: none;

    cursor: pointer;

    box-shadow:
        0 4px 12px rgba(37, 99, 235, .22);

    transition:
        transform var(--transition),
        box-shadow var(--transition),
        filter var(--transition);
}

button:hover,
.button:hover {
    color: white;

    filter: brightness(1.04);

    box-shadow:
        0 7px 18px rgba(37, 99, 235, .26);
}

button:active,
.button:active {
    transform: scale(.97);

    box-shadow:
        0 2px 7px rgba(37, 99, 235, .18);
}

button:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
}


/* =========================================================
   GRID
   ========================================================= */

.grid {
    display: grid;

    grid-template-columns:
        repeat(
            auto-fit,
            minmax(230px, 1fr)
        );

    gap: 18px;
}


/* =========================================================
   CARD
   ========================================================= */

.card {
    background: var(--surface);

    padding: 20px;

    border:
        1px solid rgba(229, 231, 235, .8);

    border-radius: var(--radius);

    box-shadow: var(--shadow-sm);

    transition:
        transform var(--transition),
        box-shadow var(--transition);
}

.card:hover {
    transform: translateY(-2px);

    box-shadow:
        0 10px 28px rgba(15, 23, 42, .09);
}


/* =========================================================
   MESSAGES
   ========================================================= */

.error,
.success {
    padding: 13px 15px;

    margin: 16px 0;

    border-radius: var(--radius-sm);

    font-size: 14px;

    border: 1px solid transparent;
}

.error {
    background: var(--danger-bg);
    color: #991b1b;

    border-color: #fecaca;
}

.success {
    background: var(--success-bg);
    color: #166534;

    border-color: #bbf7d0;
}


/* =========================================================
   TABLE
   ========================================================= */

table {
    width: 100%;

    border-collapse: separate;
    border-spacing: 0;

    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: var(--radius);

    overflow: hidden;

    box-shadow: var(--shadow-sm);
}

th,
td {
    padding: 13px 15px;

    border-bottom: 1px solid var(--border);

    text-align: left;

    vertical-align: middle;
}

th {
    background: var(--surface-soft);

    color: #374151;

    font-size: 13px;
    font-weight: 700;
}

td {
    color: #374151;
}

tr:last-child td {
    border-bottom: none;
}

table a {
    color: var(--primary);
    font-weight: 600;
}

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


/* =========================================================
   LESSON
   ========================================================= */

.lesson {
    background: var(--surface);

    padding: 22px;

    margin: 18px 0;

    border:
        1px solid rgba(229, 231, 235, .8);

    border-radius: var(--radius);

    box-shadow: var(--shadow-sm);
}


/* =========================================================
   HEADINGS
   ========================================================= */

h1,
h2,
h3,
h4 {
    margin-top: 0;

    line-height: 1.25;

    letter-spacing: -.02em;
}

h1 {
    font-size: clamp(26px, 5vw, 36px);
}

h2 {
    font-size: clamp(22px, 4vw, 30px);
}

h3 {
    font-size: 19px;
}


/* =========================================================
   SMALL DEVICES
   ========================================================= */

@media (max-width: 600px) {

    body {
        font-size: 14px;
    }

    header {
        padding:
            env(safe-area-inset-top)
            0
            10px;
    }

    .container {
        width: 94%;
    }

    main {
        padding: 22px 0 35px;
    }

    .grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .card,
    .lesson {
        padding: 17px;
        border-radius: 15px;
    }

    input,
    textarea,
    select {
        min-height: 48px;
        font-size: 16px;
    }

    button,
    .button {
        min-height: 46px;
    }

    /*
       Make tables horizontally scrollable
       without breaking the page.
    */

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;

        font-size: 13px;
    }

    th,
    td {
        padding: 11px 12px;
    }

    .center {
        padding-top: 65px;
    }
}


/* =========================================================
   VERY SMALL PHONES
   ========================================================= */

@media (max-width: 380px) {

    .container {
        width: 92%;
    }

    .nav {
        gap: 5px;
    }

    .nav a {
        padding: 7px 9px;
    }

    .card,
    .lesson {
        padding: 15px;
    }
}


/* =========================================================
   REDUCE MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;

        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* =========================================================
   APP SKELETON LOADING
   ========================================================= */

#appSkeleton {
   display: none;
   padding: 22px 0 40px;
}

#appSkeleton.active {
   display: block;
}


/* Skeleton animation */

.skeleton {
   position: relative;
   overflow: hidden;

   background: #e9edf3;

   border-radius: 9px;

   color: transparent !important;

   pointer-events: none;
}

.skeleton::after {
   content: "";

   position: absolute;
   inset: 0;

   transform: translateX(-100%);

   background:
       linear-gradient(
           90deg,
           transparent,
           rgba(255,255,255,.65),
           transparent
       );

   animation: skeletonShimmer 1.35s infinite;
}

@keyframes skeletonShimmer {

   100% {
       transform: translateX(100%);
   }

}


/* =========================================================
  DASHBOARD SKELETON
  ========================================================= */

.skeleton-title {
   width: 45%;
   height: 28px;
   margin-bottom: 20px;
}

.skeleton-text {
   height: 14px;
   margin: 9px 0;
}

.skeleton-text.short {
   width: 40%;
}

.skeleton-text.medium {
   width: 65%;
}

.skeleton-text.long {
   width: 90%;
}


/* =========================================================
  CARDS
  ========================================================= */

.skeleton-card {
   background: #fff;

   padding: 20px;

   border-radius: 16px;

   border: 1px solid #e5e7eb;

   box-shadow:
       0 1px 3px rgba(0,0,0,.05);
}

.skeleton-image {
   width: 100%;
   height: 150px;

   margin-bottom: 16px;

   border-radius: 12px;
}

.skeleton-button {
   width: 120px;
   height: 44px;

   margin-top: 16px;

   border-radius: 10px;
}


/* =========================================================
  AVATAR / PROFILE
  ========================================================= */

.skeleton-avatar {
   width: 50px;
   height: 50px;

   border-radius: 50%;
}


/* =========================================================
  LIST
  ========================================================= */

.skeleton-list {
   display: flex;
   flex-direction: column;
   gap: 14px;
}

.skeleton-list-item {
   display: flex;
   align-items: center;

   gap: 12px;
}


/* =========================================================
  LESSON
  ========================================================= */

.skeleton-lesson {
   background: #fff;

   padding: 20px;

   border-radius: 16px;

   border: 1px solid #e5e7eb;
}

.skeleton-lesson .skeleton-image {
   height: 220px;
}


/* =========================================================
  TABLE
  ========================================================= */

.skeleton-table {
   background: #fff;

   border-radius: 15px;

   overflow: hidden;

   border: 1px solid #e5e7eb;
}

.skeleton-table-row {
   display: grid;

   grid-template-columns:
       1fr
       1fr
       1fr
       100px;

   gap: 15px;

   padding: 15px;

   border-bottom: 1px solid #e5e7eb;
}


/* =========================================================
  MOBILE
  ========================================================= */

@media (max-width: 600px) {

   #appSkeleton {
       padding: 18px 0 30px;
   }

   .skeleton-card {
       padding: 17px;
       border-radius: 15px;
   }

   .skeleton-image {
       height: 140px;
   }

   .skeleton-lesson .skeleton-image {
       height: 180px;
   }

   .skeleton-table-row {
       grid-template-columns: 1fr 1fr;
       gap: 10px;
   }
}


/* =========================================================
  REDUCED MOTION
  ========================================================= */

@media (prefers-reduced-motion: reduce) {

   .skeleton::after {
       animation: none;
   }

}