/* 
 * Certificate Management System - Design System and Theme Style
 */

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

:root {
    /* Fonts */
    --font-main: 'Outfit', sans-serif;
    --font-alt: 'Inter', sans-serif;
    --font-cert-serif: 'Cinzel', serif;
    --font-cert-script: 'Great Vibes', cursive;
    
    /* Animation speed */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Light Mode Variables */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-surface: #ffffff;
    --bg-sidebar: #0f172a;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-sidebar: #f8fafc;
    --border-color: #e2e8f0;
    --border-accent: #cbd5e1;
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(255, 255, 255, 0.6);
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 8px 30px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.08);
    
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-rgb: 79, 70, 229;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg-primary: #090d16;
    --bg-surface: #111827;
    --bg-sidebar: #0a0d16;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-sidebar: #f8fafc;
    --border-color: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(17, 24, 39, 0.5);
    --card-border: rgba(255, 255, 255, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-rgb: 99, 102, 241;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
}

/* Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color var(--transition-normal), color var(--transition-normal);
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

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

/* Glassmorphism Styles */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal), background-color var(--transition-normal);
}

.glass-panel-hover:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(var(--primary-rgb), 0.2);
}

/* Scrollbar Style */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-accent);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Buttons Styling */
.btn-premium {
    background: linear-gradient(135deg, var(--primary) 0%, rgba(var(--primary-rgb), 0.8) 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.3);
    transition: all var(--transition-normal);
}
.btn-premium:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary) 100%);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.45);
}
.btn-premium:active {
    transform: translateY(0);
}

/* App Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Admin Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    transition: all var(--transition-normal);
    z-index: 100;
    position: relative;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand i {
    color: var(--primary);
    font-size: 1.5rem;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.sidebar-menu-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(248, 250, 252, 0.7);
    border-radius: 10px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.sidebar-menu-item a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-menu-item.active a {
    color: #ffffff;
    background: var(--primary);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.85rem;
    color: rgba(248, 250, 252, 0.5);
    text-align: center;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-y: auto;
}

/* Header Area */
.main-header {
    background: var(--bg-surface);
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-normal);
}

.content-body {
    padding: 30px;
    flex: 1;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
}
.theme-toggle-btn:hover {
    background: var(--bg-primary);
    color: var(--primary);
    border-color: var(--primary);
}

/* Mobile Sidebar Drawer Toggle */
.sidebar-toggler {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Statistics Cards */
.stats-card {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.stats-info h6 {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}
.stats-info h2 {
    font-size: 2rem;
    margin-bottom: 0;
}
.stats-icon-box {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}
.stats-primary {
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary);
}
.stats-success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}
.stats-warning {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}
.stats-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

/* Custom Table Design */
.custom-table-container {
    overflow-x: auto;
}
.custom-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
}
.custom-table th {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 18px;
}
.custom-table tbody tr {
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}
.custom-table tbody tr:hover {
    transform: scale(1.005);
    background: var(--bg-surface);
    box-shadow: var(--shadow-md);
}
.custom-table td {
    padding: 16px 18px;
    border-top: 1px solid var(--card-border);
    border-bottom: 1px solid var(--card-border);
    color: var(--text-primary);
}
.custom-table td:first-child {
    border-left: 1px solid var(--card-border);
    border-radius: 12px 0 0 12px;
}
.custom-table td:last-child {
    border-right: 1px solid var(--card-border);
    border-radius: 0 12px 12px 0;
}

/* Badge Styling */
.badge-custom {
    padding: 6px 12px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.75rem;
}
.badge-free {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}
.badge-paid {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

/* Forms styling */
.form-label {
    font-weight: 600;
    color: var(--text-secondary);
}
.glass-input {
    background: rgba(15, 23, 42, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 11px 16px;
    transition: all var(--transition-fast);
}
[data-theme="dark"] .glass-input {
    background: rgba(15, 23, 42, 0.4);
}
.glass-input:focus {
    background: var(--bg-surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
    color: var(--text-primary);
}

/* Public Search Area */
.search-hero {
    max-width: 800px;
    margin: 40px auto;
    text-align: center;
}
.search-card {
    padding: 35px;
    border-radius: 24px;
}

/* ==========================================================================
   Certificate Rendering Container (Web and Print layouts)
   ========================================================================== */
.certificate-preview-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
    overflow-x: auto;
}

.certificate-layout {
    width: 950px;
    height: 670px;
    position: relative;
    box-sizing: border-box;
    padding: 50px 70px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    background-color: #ffffff;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    color: #1e293b;
    overflow: hidden;
}

/* Template 1: Free Template (Green Theme) */
.certificate-free {
    border: 18px solid #065f46;
    outline: 4px solid #10b981;
    outline-offset: -10px;
    /* Soft watermark effect using local CSS gradients */
    background-image: radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.03) 0%, transparent 40%),
                      radial-gradient(circle at 90% 80%, rgba(6, 95, 70, 0.03) 0%, transparent 40%);
}

/* Template 2: Paid Template (Premium Gold Theme) */
.certificate-paid {
    border: 22px solid #1e1b4b;
    outline: 5px double #d97706; /* Gold borders */
    outline-offset: -12px;
    background-image: radial-gradient(circle at 20% 30%, rgba(217, 119, 6, 0.04) 0%, transparent 50%),
                      radial-gradient(circle at 80% 70%, rgba(217, 119, 6, 0.04) 0%, transparent 50%);
}

/* Certificate Typography */
.cert-header {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.cert-logo {
    max-height: 65px;
    max-width: 180px;
    object-fit: contain;
    margin-bottom: 15px;
}
.cert-title-free {
    font-family: var(--font-cert-serif);
    font-weight: 700;
    font-size: 2rem;
    color: #065f46;
    letter-spacing: 0.1em;
    margin-bottom: 5px;
}
.cert-title-paid {
    font-family: var(--font-cert-serif);
    font-weight: 800;
    font-size: 2.25rem;
    color: #b45309; /* Goldish primary */
    letter-spacing: 0.15em;
    margin-bottom: 5px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}
.cert-subtitle {
    font-family: var(--font-alt);
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #64748b;
}

.cert-body {
    margin: 20px 0;
    width: 100%;
}
.cert-award-text {
    font-size: 1.05rem;
    color: #475569;
    font-style: italic;
    margin-bottom: 12px;
}
.cert-name {
    font-family: var(--font-cert-script);
    font-size: 3.5rem;
    color: #0f172a;
    font-weight: 600;
    line-height: 1.2;
    margin: 10px 0 15px 0;
}
.cert-reason {
    font-size: 1.05rem;
    line-height: 1.6;
    color: #475569;
    max-width: 650px;
    margin: 0 auto;
}
.cert-reason strong {
    color: #0f172a;
}

.cert-footer {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 10px;
}
.cert-meta-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 200px;
}
.cert-meta-item.left {
    align-items: flex-start;
    text-align: left;
}
.cert-meta-item.right {
    align-items: flex-end;
    text-align: right;
}
.cert-meta-label {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 6px;
    border-top: 1px solid #cbd5e1;
    padding-top: 6px;
    width: 100%;
}
.cert-signature {
    max-height: 55px;
    max-width: 150px;
    object-fit: contain;
}
.cert-qr {
    width: 70px;
    height: 70px;
    object-fit: contain;
}
.cert-id-badge {
    font-size: 0.75rem;
    font-family: var(--font-alt);
    background: #f1f5f9;
    color: #475569;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 500;
}

/* ==========================================================================
   Responsive media queries and mobile optimizations
   ========================================================================== */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        height: 100%;
        box-shadow: 0 0 20px rgba(0,0,0,0.3);
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .sidebar-toggler {
        display: block;
    }
    
    .main-header {
        padding: 0 20px;
    }
    
    .content-body {
        padding: 20px;
    }
}

@media (max-width: 576px) {
    .content-body {
        padding: 15px;
    }
    .stats-card {
        padding: 18px;
    }
    .search-card {
        padding: 20px;
    }
}

/* Certificate resizer for smaller viewports */
@media (max-width: 980px) {
    .certificate-layout {
        transform: scale(0.8);
        transform-origin: center center;
    }
    .certificate-preview-container {
        height: 580px;
    }
}

@media (max-width: 768px) {
    .certificate-layout {
        transform: scale(0.6);
        transform-origin: center center;
    }
    .certificate-preview-container {
        height: 450px;
    }
}

@media (max-width: 576px) {
    .certificate-layout {
        transform: scale(0.42);
        transform-origin: center center;
    }
    .certificate-preview-container {
        height: 330px;
    }
}

@media (max-width: 420px) {
    .certificate-layout {
        transform: scale(0.35);
        transform-origin: center center;
    }
    .certificate-preview-container {
        height: 280px;
    }
}
