/* ============================================================
   Kattrapin LMS – Component Styles
   Native CSS (no @apply – Tailwind is loaded via CDN only)
   ============================================================ */

/* ----- Buttons ----- */
.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1.125rem;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.25;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background-color: #2563eb;
    color: #ffffff;
    border: 1px solid #1d4ed8;
}
.btn-primary:hover {
    background-color: #1d4ed8;
    box-shadow: 0 1px 4px rgba(37,99,235,0.3);
}

.btn-secondary {
    background-color: #f3f4f6;
    color: #1f2937;
    border: 1px solid #d1d5db;
}
.btn-secondary:hover {
    background-color: #e5e7eb;
    border-color: #9ca3af;
}

.btn-danger {
    background-color: #dc2626;
    color: #ffffff;
    border: 1px solid #b91c1c;
}
.btn-danger:hover {
    background-color: #b91c1c;
    box-shadow: 0 1px 4px rgba(220,38,38,0.3);
}

.btn-success {
    background-color: #16a34a;
    color: #ffffff;
    border: 1px solid #15803d;
    cursor: default;
}
.btn-success:hover {
    background-color: #15803d;
}

.btn-small {
    padding: 0.3125rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: 0.375rem;
}

button:disabled,
.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ----- Manage Tabs ----- */
.manage-tab {
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.manage-tab:hover {
    color: #1d4ed8;
}
.manage-tab.active {
    color: #1d4ed8;
    border-bottom-color: #1d4ed8;
}

/* ----- Cards ----- */
.card {
    background-color: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
}

.card-hover {
    background-color: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
    text-decoration: none;
    display: block;
    color: inherit;
}
.card-hover:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    border-color: #bfdbfe;
    transform: translateY(-1px);
}

/* ----- Forms ----- */
.form-input {
    display: block;
    width: 100%;
    padding: 0.5625rem 0.875rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: #111827;
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
}
.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.375rem;
}

/* ----- Badges ----- */
.badge-success,
.badge-warning,
.badge-danger,
.badge-info {
    display: inline-block;
    padding: 0.1875rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.badge-success  { background-color: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.badge-warning  { background-color: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-danger   { background-color: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.badge-info     { background-color: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ----- Tables ----- */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.table thead {
    background-color: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 1;
}

.table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: #1f2937;
    vertical-align: middle;
}

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

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

/* ----- Loading Spinner ----- */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #d1d5db;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ----- Toasts ----- */
.toast-error,
.toast-success {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    padding: 0.875rem 1.25rem;
    border-radius: 0.625rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 0.9375rem;
    font-weight: 500;
    color: #ffffff;
    z-index: 9999;
    max-width: 22rem;
}
.toast-error   { background-color: #ef4444; }
.toast-success { background-color: #22c55e; }

/* ----- Learning Page Layout ----- */
.learn-hero {
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid #e2e8f0;
    border-radius: 0.875rem;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    gap: 1.25rem;
    align-items: flex-start;
}

.learn-hero-progress {
    min-width: 170px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 0.75rem;
}

.learn-hero-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
}

.learn-hero-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #1d4ed8 0%, #0f766e 100%);
}

.learn-page-shell {
    position: relative;
}

.learn-page-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.learn-page-back {
    color: #1d4ed8;
    font-size: 0.875rem;
    text-decoration: none;
    font-weight: 600;
}

.learn-page-title {
    margin: 0;
    font-size: 2.25rem;
    line-height: 1.1;
    font-weight: 700;
    color: #111827;
}

.learn-page-subtitle {
    margin: 0.375rem 0 0;
    color: #6b7280;
    font-size: 1rem;
}

.learn-index-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.learn-index-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.learn-index-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
}

.learn-index-subtitle {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: #64748b;
}

.learn-index-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.lesson-row,
.quiz-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.625rem;
    padding: 0.75rem 0.875rem;
    margin-bottom: 0.625rem;
    background: #ffffff;
}

.lesson-row {
    margin-bottom: 0;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.lesson-row-active {
    border-color: #bfdbfe;
    background: linear-gradient(180deg, #ffffff 0%, #eff6ff 100%);
}

.lesson-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 9999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.8125rem;
    font-weight: 700;
    flex-shrink: 0;
}

.lesson-main {
    flex: 1;
    min-width: 0;
}

.learn-index-module-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.learn-index-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: #64748b;
    text-transform: uppercase;
    margin-bottom: 0.45rem;
}

.learn-index-progress {
    height: 0.4rem;
    border-radius: 9999px;
    background: #e2e8f0;
    overflow: hidden;
}

.learn-index-progress span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #2563eb 0%, #0f766e 100%);
}

.learn-index-current {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    background: #e0f2fe;
    color: #0f172a;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.35rem 0.65rem;
}

.learn-index-link {
    color: #1d4ed8;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
}

.learn-index-quiz-row {
    margin-top: 0.35rem;
}

.learn-index-quiz-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    letter-spacing: 0.01em;
}

.learn-index-quiz-passed {
    background: #dcfce7;
    color: #15803d;
}

.learn-index-quiz-failed {
    background: #fee2e2;
    color: #b91c1c;
}

.learn-index-quiz-pending {
    background: #fef9c3;
    color: #854d0e;
}

.learn-stage-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.learn-stage-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.learn-stage-copy {
    min-width: 0;
}

.learn-stage-kicker {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 0.35rem 0.7rem;
    text-transform: uppercase;
}

.learn-stage-title {
    margin: 0.65rem 0 0;
    font-size: 2rem;
    line-height: 1.1;
    font-weight: 700;
    color: #111827;
}

.learn-stage-subtitle {
    margin-top: 0.5rem;
    color: #6b7280;
    font-size: 0.95rem;
}

.learn-progress-panel {
    min-width: 220px;
    background: #ffffff;
    border: 1px solid #dbeafe;
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.08);
}

.learn-progress-label {
    color: #64748b;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.learn-progress-percent {
    margin: 0.35rem 0 0.75rem;
    font-size: 2rem;
    line-height: 1;
    font-weight: 700;
    color: #0f172a;
}

.learn-progress-foot {
    font-size: 0.875rem;
    color: #475569;
    margin-top: 0.55rem;
}

.learn-progress-resume {
    color: #0f766e;
    font-weight: 600;
}

.learn-media-embed {
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid #dbe4f0;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
}

.learn-video-frame,
.learn-doc-frame {
    display: block;
    width: 100%;
    border: 0;
    background: #020617;
}

.learn-meta-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    color: #475569;
    font-size: 0.9375rem;
}

.learn-quiz-card {
    border-style: solid;
    border-width: 1px;
    border-color: #e2e8f0;
    background: linear-gradient(180deg, #ffffff 0%, #fffbeb 100%);
}

.lesson-actions a {
    font-size: 0.8125rem;
    text-decoration: none;
}

@media (max-width: 768px) {
    .learn-stage-header,
    .learn-hero {
        flex-direction: column;
    }

    .learn-progress-panel {
        width: 100%;
        min-width: 0;
    }

    .learn-page-title {
        font-size: 1.875rem;
    }

    .learn-stage-title {
        font-size: 1.5rem;
    }

    .lesson-row {
        align-items: flex-start;
    }

    .lesson-actions {
        align-self: center;
    }

    .learn-hero-progress {
        width: 100%;
        min-width: 0;
    }
}
