/* ============================
   Loveworld Foundation School Certificate Portal
   Main Stylesheet
   ============================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Playfair+Display:wght@700;800&display=swap');

/* CSS Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --primary-light: #eef0ff;
    --success: #28a745;
    --success-light: #e8f5e9;
    --danger: #dc3545;
    --danger-light: #fce4e6;
    --warning: #ffc107;
    --warning-light: #fff8e1;
    --dark: #1a1a2e;
    --dark-secondary: #16213e;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --white: #ffffff;
    --sidebar-width: 250px;
    --header-height: 65px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
}

/* ============================
   LOGIN PAGE
   ============================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 20px;
}

.login-container {
    display: flex;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    max-width: 960px;
    width: 100%;
    min-height: 520px;
}

.login-left {
    flex: 1;
    background: var(--white);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
}

.login-left h1 {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 25px;
    line-height: 1.3;
}

.login-left .login-image {
    max-width: 380px;
    width: 100%;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.login-right {
    flex: 1;
    padding: 50px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-right h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
}

.login-right p.subtitle {
    color: var(--gray-600);
    font-size: 14px;
    margin-bottom: 35px;
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    color: var(--gray-800);
    background: var(--white);
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.form-group input::placeholder {
    color: var(--gray-500);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.35);
}

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

.btn-success:hover {
    background: #218838;
    transform: translateY(-1px);
}

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

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.btn-warning {
    background: var(--warning);
    color: var(--dark);
}

.btn-teal {
    background: #20c997;
    color: var(--white);
}

.btn-teal:hover {
    background: #1baa80;
}

.btn-sm {
    padding: 7px 16px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

/* Logo image styling */
.brand-icon {
    flex-shrink: 0 !important;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)) !important;
    transition: transform 0.3s ease !important;
}

/* Style for <img> logos */
.brand-icon[src] {
    object-fit: contain !important;
    border-radius: 8px !important;
    background: rgba(255,255,255,0.1) !important;
    padding: 4px !important;
}

.sidebar-brand:hover .brand-icon {
    transform: rotate(5deg) scale(1.05) !important;
}

/* ============================
   LAYOUT: SIDEBAR + MAIN
   ============================ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar-brand {
    padding: 20px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.sidebar-brand .brand-icon {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
}

.sidebar-brand .brand-text {
    font-weight: 700;
    font-size: 16px;
    color: var(--dark);
    line-height: 1.3;
}

.sidebar-brand .brand-text span {
    display: block;
    font-size: 11px;
    color: var(--gray-600);
    font-weight: 400;
}

.sidebar-nav {
    padding: 15px 0;
    flex: 1;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--gray-600);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-item:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.sidebar-nav .nav-item.active {
    color: var(--primary);
    background: var(--primary-light);
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-nav .nav-item .nav-icon {
    font-size: 18px;
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--gray-200);
    font-size: 11px;
    color: var(--gray-500);
    line-height: 1.6;
}

.sidebar-footer strong {
    color: var(--gray-700);
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top header */
.top-header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 30px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-header .page-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-header .page-title .hamburger {
    font-size: 22px;
    color: var(--gray-600);
    cursor: pointer;
    display: none;
}

.top-header .page-title h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
}

.top-header .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-header .user-info .user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gray-200);
}

.top-header .user-info .user-details {
    text-align: right;
}

.top-header .user-info .user-details .user-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--dark);
}

.top-header .user-info .user-details .user-role {
    font-size: 12px;
    color: var(--gray-500);
}

/* Content area */
.content-area {
    padding: 30px;
    flex: 1;
}

/* ============================
   STAT CARDS
   ============================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 28px 25px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
    border: 1px solid var(--gray-200);
}

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

.stat-card .stat-value {
    font-size: 42px;
    font-weight: 800;
    color: var(--dark);
    line-height: 1;
    margin-bottom: 6px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
}

.stat-card .stat-icon {
    font-size: 32px;
    color: var(--primary);
}

/* ============================
   CARDS & PANELS
   ============================ */
.card {
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    margin-bottom: 25px;
    overflow: hidden;
}

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

.card-header h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--dark);
}

.card-body {
    padding: 25px;
}

/* ============================
   TABLES
   ============================ */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead th {
    background: var(--gray-100);
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-700);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: var(--gray-100);
}

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

/* ============================
   STATUS BADGES
   ============================ */
.badge {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-light);
    color: #e09200;
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

/* ============================
   FORM STYLES (PANELS)
   ============================ */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

/* File input styling */
.file-input-wrapper {
    position: relative;
}

.file-input-wrapper input[type="file"] {
    padding: 10px;
    border: 1.5px dashed var(--gray-400);
    border-radius: var(--radius-sm);
    background: var(--gray-100);
    cursor: pointer;
    width: 100%;
}

/* ============================
   ALERTS / FLASH MESSAGES
   ============================ */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: var(--success-light);
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: var(--danger-light);
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-info {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid #b8c9ff;
}

/* ============================
   TEMPLATE POSITION EDITOR
   ============================ */
.template-editor {
    position: relative;
    display: inline-block;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #f0f0f0;
}

.template-editor img {
    display: block;
    max-width: 100%;
    height: auto;
}

.template-editor .marker {
    position: absolute;
    background: rgba(255, 0, 0, 0.7);
    color: white;
    padding: 2px 8px;
    font-size: 10px;
    border-radius: 3px;
    cursor: move;
    white-space: nowrap;
    z-index: 10;
    user-select: none;
}

.position-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.position-group {
    background: var(--gray-100);
    padding: 15px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
}

.position-group h4 {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.position-group .pos-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.position-group .pos-row label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    width: 70px;
    flex-shrink: 0;
}

.position-group .pos-row input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 13px;
    width: 80px;
}

/* ============================
   SECTION: TWO COL LAYOUT
   ============================ */
.two-col-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

/* ============================
   FOOTER
   ============================ */
.content-footer {
    padding: 20px 30px;
    text-align: center;
    font-size: 13px;
    color: var(--gray-500);
    border-top: 1px solid var(--gray-200);
}

.content-footer a {
    color: var(--primary);
    font-weight: 600;
}

/* ============================
   ACTION BUTTONS IN TABLE
   ============================ */
.action-btns {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

/* ============================
   MOBILE RESPONSIVE
   ============================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .top-header .page-title .hamburger {
        display: block;
    }

    .two-col-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .login-container {
        flex-direction: column;
    }

    .login-left {
        padding: 30px 20px;
    }

    .login-right {
        padding: 30px 20px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .content-area {
        padding: 20px 15px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .position-controls {
        grid-template-columns: 1fr;
    }
}

/* ============================
   UTILITY CLASSES
   ============================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--gray-500) !important; }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.p-0 { padding: 0 !important; }
.d-flex { display: flex; }
.gap-2 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--gray-100);
}
::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--gray-300);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Password visibility */
.password-cell {
    font-family: monospace;
    letter-spacing: 1px;
}

/* Template preview canvas */
.template-preview-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    overflow: auto;
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 10px;
    background: var(--gray-100);
}

.template-preview-container canvas {
    display: block;
    max-width: 100%;
    cursor: crosshair;
}

/* Notice banner */
.notice-banner {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    margin-bottom: 25px;
    font-size: 14px;
    font-weight: 600;
    color: #155724;
    text-align: center;
}