/* =====================================================
   Customer Portal Styles
   Modern, clean design with purple/indigo gradient theme
   ===================================================== */

:root {
    /* ── Brand colors: set by theme.php via portal_customization DB key ──
       These are fallback defaults only. theme.php injects the real values
       as a <style id="portal-theme"> block BEFORE this file loads.
       We intentionally do NOT hardcode brand colors here anymore. ── */

    /* Neutral grays — not themeable */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Semantic colors — not themeable */
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 40px -10px rgba(0, 0, 0, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--page-bg, var(--gray-50));
    color: var(--text-color, var(--gray-800));
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* =====================================================
   Layout
   ===================================================== */

.portal-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.portal-main {
    flex: 1;
    padding: 30px 20px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.portal-container {
    max-width: 1200px;
    margin: 0 auto;
}

/* =====================================================
   Navigation Header
   ===================================================== */

.portal-header {
    background: var(--gradient-primary);
    color: white;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.portal-nav {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.portal-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: white;
    font-weight: 700;
    font-size: 1.25rem;
}

.portal-logo i {
    font-size: 1.5rem;
}

.portal-logo:hover {
    color: white;
    opacity: 0.9;
}

.portal-nav-links {
    display: flex;
    align-items: center;
    gap: 5px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.portal-nav-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 500;
}

.portal-nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.portal-nav-link.active {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.portal-nav-link i {
    font-size: 1rem;
}

.portal-user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}

.portal-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.portal-user-avatar:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.portal-mobile-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* =====================================================
   Cards
   ===================================================== */

.portal-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: all 0.3s;
}

.portal-card:hover {
    box-shadow: var(--shadow-lg);
}

.portal-card-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.portal-card-header h2,
.portal-card-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 10px;
}

.portal-card-header i {
    color: var(--primary);
}

.portal-card-body {
    padding: 25px;
}

.portal-card-footer {
    padding: 15px 25px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-100);
}

/* Gradient Header Card */
.portal-card.gradient-header .portal-card-header {
    background: var(--gradient-primary);
    color: white;
    border-bottom: none;
}

.portal-card.gradient-header .portal-card-header h2,
.portal-card.gradient-header .portal-card-header h3,
.portal-card.gradient-header .portal-card-header i {
    color: white;
}

/* =====================================================
   Dashboard Stats
   ===================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 20px;
    transition: all 0.3s;
    border-left: 4px solid var(--primary);
}

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

.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.info { border-left-color: var(--info); }
.stat-card.danger { border-left-color: var(--danger); }

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.stat-card.success .stat-icon { background: var(--gradient-success); }
.stat-card.warning .stat-icon { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.stat-card.info .stat-icon { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); }

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--gray-500);
}

/* =====================================================
   Forms
   ===================================================== */

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-text {
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--gray-500);
}

.form-text.text-danger {
    color: var(--danger);
}

.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-control {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.input-group-text {
    padding: 12px 16px;
    background: var(--gray-100);
    border: 2px solid var(--gray-200);
    border-left: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--gray-600);
}

/* Password toggle */
.password-toggle {
    position: relative;
}

.password-toggle .form-control {
    padding-right: 50px;
}

.password-toggle-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 5px;
}

.password-toggle-btn:hover {
    color: var(--gray-600);
}

/* =====================================================
   Buttons
   ===================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    line-height: 1.5;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-200);
}

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

.btn-outline:hover:not(:disabled) {
    background: var(--primary);
    color: white;
}

/* View Details button — color comes from --detail-btn theme variable */
.detail-btn {
    background: transparent !important;
    border: 2px solid var(--detail-btn, var(--primary)) !important;
    color: var(--detail-btn, var(--primary)) !important;
    font-weight: 600;
}

.detail-btn:hover {
    background: var(--detail-btn, var(--primary)) !important;
    color: #fff !important;
}

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

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.1rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* =====================================================
   Alerts
   ===================================================== */

.alert {
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert i {
    font-size: 1.2rem;
    margin-top: 2px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success);
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning);
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--info);
}

/* =====================================================
   Class Cards
   ===================================================== */

.class-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.class-item {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    transition: all 0.2s;
}

.class-item:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.class-date {
    text-align: center;
    min-width: 70px;
    padding: 10px;
    background: var(--gradient-primary);
    border-radius: var(--radius-sm);
    color: white;
}

.class-date-month {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
}

.class-date-day {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.class-info {
    flex: 1;
}

.class-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 5px;
}

.class-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 0.9rem;
    color: var(--gray-500);
}

.class-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.class-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.class-status.confirmed {
    background: #d1fae5;
    color: #065f46;
}

.class-status.pending {
    background: #fef3c7;
    color: #92400e;
}

.class-status.cancelled {
    background: #fee2e2;
    color: #991b1b;
}

.class-status.completed {
    background: #dbeafe;
    color: #1e40af;
}

.class-actions {
    display: flex;
    gap: 10px;
}

/* =====================================================
   Registration Details
   ===================================================== */

.registration-header {
    background: var(--gradient-primary);
    color: white;
    padding: 40px;
    border-radius: var(--radius) var(--radius) 0 0;
    text-align: center;
}

.registration-header h1 {
    margin: 0 0 10px 0;
    font-size: 1.75rem;
}

.registration-header .class-meta {
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}

.detail-item {
    padding: 15px 0;
    border-bottom: 1px solid var(--gray-100);
}

.detail-label {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 5px;
}

.detail-value {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--gray-800);
}

/* =====================================================
   Profile Page
   ===================================================== */

.profile-header {
    display: flex;
    align-items: center;
    gap: 25px;
    margin-bottom: 30px;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
}

.profile-info h1 {
    margin: 0 0 5px 0;
    font-size: 1.5rem;
}

.profile-info p {
    margin: 0;
    color: var(--gray-500);
}

.profile-stats {
    display: flex;
    gap: 30px;
    margin-top: 15px;
}

.profile-stat {
    text-align: center;
}

.profile-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.profile-stat-label {
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* =====================================================
   Payments Table
   ===================================================== */

.payments-table {
    width: 100%;
    border-collapse: collapse;
}

.payments-table th,
.payments-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.payments-table th {
    font-weight: 600;
    color: var(--gray-600);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--gray-50);
}

.payments-table tr:hover td {
    background: var(--gray-50);
}

.payment-amount {
    font-weight: 600;
    color: var(--gray-800);
}

.payment-status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.payment-status.completed {
    background: #d1fae5;
    color: #065f46;
}

.payment-status.pending {
    background: #fef3c7;
    color: #92400e;
}

.payment-status.failed {
    background: #fee2e2;
    color: #991b1b;
}

/* =====================================================
   Auth Pages
   ===================================================== */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 12%, transparent) 0%, color-mix(in srgb, var(--secondary) 12%, transparent) 100%);
}

.auth-container {
    width: 100%;
    max-width: 450px;
}

.auth-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.auth-header {
    background: var(--gradient-primary);
    color: white;
    padding: 40px;
    text-align: center;
}

.auth-header-logo {
    font-size: 3rem;
    margin-bottom: 15px;
}

.auth-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.auth-header p {
    margin: 10px 0 0 0;
    opacity: 0.9;
}

.auth-body {
    padding: 40px;
}

.auth-footer {
    padding: 20px 40px;
    background: var(--gray-50);
    text-align: center;
    border-top: 1px solid var(--gray-100);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 25px 0;
    color: var(--gray-400);
    font-size: 0.9rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-200);
}

/* =====================================================
   Browse Classes
   ===================================================== */

.class-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
}

.class-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s;
}

.class-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.class-card-header {
    background: var(--gradient-primary);
    color: white;
    padding: 25px;
    position: relative;
}

.class-card-header h3 {
    margin: 0 0 10px 0;
    font-size: 1.25rem;
}

.class-card-header .class-meta {
    color: rgba(255, 255, 255, 0.9);
}

.class-card-spots {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.class-card-body {
    padding: 25px;
}

.class-card-description {
    color: var(--gray-600);
    margin-bottom: 20px;
    line-height: 1.7;
}

.class-card-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 15px;
}

.class-card-price span {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--gray-500);
}

/* =====================================================
   Empty States
   ===================================================== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    margin: 0 0 10px 0;
    color: var(--gray-700);
}

.empty-state p {
    margin: 0 0 25px 0;
}

/* =====================================================
   Loading States
   ===================================================== */

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--gray-200);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
}

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

.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* =====================================================
   Footer
   ===================================================== */

.portal-footer {
    background: var(--gray-800);
    color: var(--gray-400);
    padding: 30px 20px;
    text-align: center;
    font-size: 0.9rem;
}

.portal-footer a {
    color: var(--gray-300);
    text-decoration: none;
}

.portal-footer a:hover {
    color: white;
}

/* =====================================================
   Responsive
   ===================================================== */

@media (max-width: 992px) {
    .portal-nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        padding: 15px;
        flex-direction: column;
        box-shadow: var(--shadow-lg);
    }
    
    .portal-nav-links.show {
        display: flex;
    }
    
    .portal-nav-link {
        color: var(--gray-700);
        padding: 12px 16px;
    }
    
    .portal-nav-link:hover,
    .portal-nav-link.active {
        background: var(--gray-100);
        color: var(--primary);
    }
    
    .portal-mobile-toggle {
        display: block;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .class-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .class-date {
        min-width: auto;
        display: flex;
        gap: 10px;
        align-items: center;
    }
    
    .class-date-day {
        font-size: 1.5rem;
    }
    
    .class-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .profile-stats {
        justify-content: center;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .auth-body {
        padding: 30px 25px;
    }
    
    .auth-header {
        padding: 30px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .portal-main {
        padding: 20px 15px;
    }
    
    .portal-card-body {
        padding: 20px;
    }
}

/* =====================================================
   Utilities
   ===================================================== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

.hidden { display: none; }

/* Recurring series badge — color controlled by admin Portal Design > Series Badge */
.series-badge { background: var(--series-badge, var(--accent)) !important; color: #fff !important; }
