/* ============================================
   ZimLearn - Component Styles
   ============================================ */

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    min-height: 48px;
    font-family: inherit;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3);
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-accent {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

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

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-ghost {
    background: var(--bg);
    color: var(--text);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    min-height: 36px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
    min-height: 52px;
    border-radius: var(--radius);
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    min-height: auto;
}

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

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: 0 2px 12px var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:active {
    transform: scale(0.98);
}

.card-elevated {
    box-shadow: 0 4px 20px var(--shadow-md);
}

/* Subject Cards */
.subject-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.subject-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 12px var(--shadow);
    border-left: 4px solid transparent;
    text-decoration: none;
    color: var(--text);
}

.subject-card:active {
    transform: scale(0.95);
}

.subject-card .subject-emoji {
    font-size: 32px;
    margin-bottom: 8px;
    display: block;
}

.subject-card .subject-name {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}

.subject-card .subject-progress {
    font-size: 11px;
    color: var(--text-light);
}

.subject-card[data-subject="English"] { border-left-color: var(--english); }
.subject-card[data-subject="Mathematics"] { border-left-color: var(--maths); }
.subject-card[data-subject="Shona"] { border-left-color: var(--shona); }
.subject-card[data-subject="Social Studies"] { border-left-color: var(--social); }
.subject-card[data-subject="Agriculture"] { border-left-color: var(--agric); }
.subject-card[data-subject="PE & Arts"] { border-left-color: var(--pe); }
.subject-card[data-subject="ICT"] { border-left-color: var(--ict); }
.subject-card[data-subject="Heritage"] { border-left-color: var(--heritage); }

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s;
    min-height: 48px;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23636E72' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}

/* ============================================
   Welcome Banner / Hero
   ============================================ */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius);
    padding: 20px;
    color: white;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.welcome-banner::after {
    content: '';
    position: absolute;
    top: -30%;
    right: -10%;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
}

.welcome-banner h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.welcome-banner p {
    font-size: 13px;
    opacity: 0.85;
    margin-bottom: 12px;
}

/* ============================================
   XP Bar
   ============================================ */
.xp-bar-wrap {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    height: 10px;
    overflow: hidden;
    position: relative;
}

.xp-bar-fill {
    height: 100%;
    background: var(--warning);
    border-radius: 10px;
    transition: width 0.5s ease;
    min-width: 4px;
}

.xp-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-top: 4px;
    opacity: 0.85;
}

/* ============================================
   Stats Row
   ============================================ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
    box-shadow: 0 2px 8px var(--shadow);
}

.stat-card .stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
}

.stat-card .stat-label {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 2px;
}

/* ============================================
   Section Headers
   ============================================ */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.section-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.section-header a {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* ============================================
   Exam Alert
   ============================================ */
.exam-alert {
    background: linear-gradient(135deg, var(--accent) 0%, #FF8E8E 100%);
    border-radius: var(--radius);
    padding: 14px 16px;
    color: white;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    animation: pulse 2s infinite;
}

.exam-alert .alert-icon {
    font-size: 24px;
}

.exam-alert .alert-text h4 {
    font-size: 14px;
    font-weight: 700;
}

.exam-alert .alert-text p {
    font-size: 12px;
    opacity: 0.9;
}

/* ============================================
   List Items
   ============================================ */
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 4px var(--shadow);
}

.list-item:active {
    transform: scale(0.98);
    background: var(--bg);
}

.list-item .item-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.list-item .item-text {
    flex: 1;
}

.list-item .item-text h4 {
    font-size: 14px;
    font-weight: 600;
}

.list-item .item-text p {
    font-size: 12px;
    color: var(--text-light);
}

.list-item .item-arrow {
    color: var(--text-muted);
    font-size: 18px;
}

/* ============================================
   Badge
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-primary { background: rgba(108,99,255,0.1); color: var(--primary); }
.badge-success { background: rgba(46,204,113,0.1); color: var(--success); }
.badge-warning { background: rgba(241,196,15,0.15); color: #D4AC0D; }
.badge-danger { background: rgba(231,76,60,0.1); color: var(--danger); }

/* ============================================
   Progress Bar (general)
   ============================================ */
.progress-bar {
    background: var(--bg);
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
    background: var(--primary);
}

/* ============================================
   Tabs
   ============================================ */
.tabs {
    display: flex;
    gap: 0;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 16px;
    overflow-x: auto;
}

.tab {
    flex: 1;
    padding: 10px 12px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    border: none;
    background: none;
    border-radius: var(--radius-xs);
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
}

.tab.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 2px 8px var(--shadow);
}

/* ============================================
   Table
   ============================================ */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 4px var(--shadow);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 13px;
}

.table th,
.table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text-light);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

/* ============================================
   Avatar
   ============================================ */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.avatar-lg {
    width: 64px;
    height: 64px;
    font-size: 24px;
}

/* ============================================
   Chip / Tag
   ============================================ */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background: var(--bg);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.chip.active {
    background: rgba(108,99,255,0.1);
    color: var(--primary);
    border-color: var(--primary);
}

.chip-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.pagination button {
    padding: 8px 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-xs);
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}

.pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================
   Leaderboard
   ============================================ */
.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    box-shadow: 0 1px 4px var(--shadow);
}

.leaderboard-rank {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    background: var(--bg);
    color: var(--text-light);
    flex-shrink: 0;
}

.leaderboard-item:nth-child(1) .leaderboard-rank {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
}

.leaderboard-item:nth-child(2) .leaderboard-rank {
    background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
    color: white;
}

.leaderboard-item:nth-child(3) .leaderboard-rank {
    background: linear-gradient(135deg, #CD7F32, #A0522D);
    color: white;
}

.leaderboard-info {
    flex: 1;
}

.leaderboard-info .name {
    font-size: 14px;
    font-weight: 600;
}

.leaderboard-info .xp {
    font-size: 12px;
    color: var(--text-light);
}

.leaderboard-item.current-user {
    border: 2px solid var(--primary);
    background: rgba(108,99,255,0.05);
}

/* ============================================
   Chart Container
   ============================================ */
.chart-container {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px var(--shadow);
}

.chart-container h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.chart-container canvas {
    max-height: 250px;
}

/* ============================================
   Notes Content
   ============================================ */
.note-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 2px 12px var(--shadow);
    line-height: 1.7;
    font-size: 15px;
}

.note-content h3 {
    font-size: 18px;
    color: var(--primary);
    margin-bottom: 12px;
}

.note-content h4 {
    font-size: 15px;
    margin-top: 16px;
    margin-bottom: 8px;
}

.note-content ul, .note-content ol {
    padding-left: 20px;
    margin-bottom: 12px;
}

.note-content li {
    margin-bottom: 4px;
}

.note-content b, .note-content strong {
    color: var(--primary-dark);
}

/* ============================================
   Profile Page
   ============================================ */
.profile-header {
    text-align: center;
    padding: 20px;
    margin-bottom: 16px;
}

.profile-header .avatar {
    margin: 0 auto 12px;
}

.profile-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.profile-header p {
    font-size: 13px;
    color: var(--text-light);
}

.badge-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.badge-item {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 12px 8px;
    text-align: center;
    box-shadow: 0 2px 8px var(--shadow);
}

.badge-item .badge-icon {
    font-size: 28px;
    margin-bottom: 4px;
}

.badge-item .badge-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-light);
}

.badge-item.locked {
    opacity: 0.3;
    filter: grayscale(1);
}

/* ============================================
   Responsive
   ============================================ */
@media (min-width: 500px) {
    .subject-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .stats-row {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 768px) {
    .modal-content {
        border-radius: var(--radius);
        max-width: 520px;
    }
    .modal-overlay {
        align-items: center;
    }

    .subject-card .subject-emoji {
        font-size: 36px;
    }

    .subject-card .subject-name {
        font-size: 14px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card .stat-value {
        font-size: 26px;
    }

    .stat-card .stat-label {
        font-size: 12px;
    }

    .welcome-banner {
        padding: 24px;
    }

    .welcome-banner h2 {
        font-size: 22px;
    }

    .welcome-banner p {
        font-size: 14px;
    }

    .badge-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .note-content {
        padding: 24px;
        font-size: 16px;
    }

    .note-content h3 {
        font-size: 20px;
    }

    .profile-header {
        padding: 24px;
    }

    .profile-header h2 {
        font-size: 22px;
    }

    .chart-container {
        padding: 20px;
    }

    .chart-container canvas {
        max-height: 300px;
    }

    .table th,
    .table td {
        padding: 12px 16px;
    }

    .table {
        font-size: 14px;
    }

    .section-header h3 {
        font-size: 18px;
    }

    .tabs {
        padding: 5px;
    }

    .tab {
        padding: 11px 16px;
        font-size: 14px;
    }
}

/* ============================================
   Tablet Landscape (1024px+)
   ============================================ */
@media (min-width: 1024px) {
    .badge-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .note-content {
        padding: 28px;
    }

    .chart-container canvas {
        max-height: 350px;
    }
}
