/**
 * QR Code Generator - Modern Design
 * Website: https://qr.ssrr.sa/
 */

/* =============================================
   CSS Variables - Modern Color Palette
   ============================================= */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #ec4899;
    --secondary-dark: #db2777;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-input: #334155;
    
    --text-primary: #0f172a;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border-color: #334155;
    --border-light: #475569;
    
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    --gradient-secondary: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    --gradient-dark: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.3);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================
   Reset & Base
   ============================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-image: 
        radial-gradient(ellipse at top, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at bottom, rgba(236, 72, 153, 0.1) 0%, transparent 50%);
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--secondary);
}

img {
    max-width: 100%;
    height: auto;
}

/* =============================================
   Header - Modern Glass Effect
   ============================================= */
.header {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-logo img {
    height: 45px;
    width: auto;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.5));
}

.header-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-nav a {
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.header-nav a::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition);
}

.header-nav a:hover {
    color: var(--text-primary);
}

.header-nav a:hover::before {
    opacity: 0.15;
}

.mobile-menu-btn {
    display: none;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
    transition: var(--transition);
}

.mobile-menu-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* =============================================
   Main Content
   ============================================= */
.main-content {
    flex: 1;
    padding: 2rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* =============================================
   Hero Section - Animated
   ============================================= */
.hero {
    text-align: center;
    padding: 3rem 0;
    margin-bottom: 2rem;
}

.hero h2 {
    font-size: 3rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.75rem;
    animation: gradientMove 3s ease infinite;
    background-size: 200% 200%;
}

@keyframes gradientMove {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.hero p {
    color: var(--text-secondary);
    font-size: 1.2rem;
}

/* =============================================
   Tabs - Modern Pill Style
   ============================================= */
.tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.tab-btn {
    padding: 1rem 2rem;
    border: none;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 2px solid transparent;
}

.tab-btn:hover {
    background: var(--bg-input);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.tab-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-glow);
}

.tab-btn svg {
    width: 20px;
    height: 20px;
}

/* =============================================
   Card - Glass Morphism
   ============================================= */
.card {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.card-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* =============================================
   Form Elements - Modern Style
   ============================================= */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg-input);
    color: var(--text-primary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-input);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
}

.color-picker {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
    background: transparent;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: 2px solid var(--border-light);
    border-radius: var(--radius-sm);
}

.color-picker-wrapper span {
    color: var(--text-secondary);
    font-family: monospace;
    font-size: 0.9rem;
}

/* =============================================
   QR Type Selector - Modern Cards
   ============================================= */
.qr-type-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.qr-type-btn {
    padding: 1.5rem 1rem;
    border: 2px solid var(--border-color);
    background: var(--bg-input);
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.qr-type-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition);
}

.qr-type-btn:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.qr-type-btn.active {
    border-color: var(--primary);
    background: transparent;
}

.qr-type-btn.active::before {
    opacity: 0.15;
}

.qr-type-btn svg {
    width: 32px;
    height: 32px;
    margin-bottom: 0.75rem;
    color: var(--primary-light);
    position: relative;
    z-index: 1;
}

.qr-type-btn span {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
}

/* =============================================
   Buttons - Gradient & Glow
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.9rem 1.75rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.btn-lg {
    padding: 1.2rem 2.5rem;
    font-size: 1.1rem;
    border-radius: var(--radius-lg);
}

.btn-block {
    width: 100%;
}

.btn svg {
    width: 20px;
    height: 20px;
}

/* =============================================
   QR Preview - Centered with Frame
   ============================================= */
.qr-preview {
    text-align: center;
    padding: 2.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    margin-top: 2rem;
    border: 2px solid var(--border-color);
    position: relative;
    min-height: 350px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.qr-preview::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: var(--gradient-primary);
    border-radius: var(--radius-xl);
    z-index: -1;
    opacity: 0.3;
    filter: blur(20px);
}

#qr-canvas {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    width: 100%;
}

#qr-canvas img {
    max-width: 100%;
    max-height: 400px;
    width: auto;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    background: white;
    padding: 15px;
    border: 3px solid var(--border-light);
}

.qr-preview canvas,
.qr-preview img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    background: white;
    padding: 15px;
}

.qr-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

/* =============================================
   Scanner Section
   ============================================= */
.scanner-container {
    text-align: center;
}

.scanner-options {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

#scanner-video {
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-xl);
    background: var(--bg-primary);
    border: 3px solid var(--primary);
    box-shadow: var(--shadow-glow);
}

.scanner-result {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-input);
    border-radius: var(--radius-lg);
    text-align: left;
    border: 2px solid var(--border-color);
}

.scanner-result pre {
    white-space: pre-wrap;
    word-break: break-all;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* File Upload - Modern Drag & Drop */
.file-upload {
    border: 3px dashed var(--border-light);
    border-radius: var(--radius-xl);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-input);
}

.file-upload:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.file-upload input {
    display: none;
}

.file-upload svg {
    width: 64px;
    height: 64px;
    color: var(--primary-light);
    margin-bottom: 1rem;
}

.file-upload p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* =============================================
   Footer
   ============================================= */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem;
    text-align: center;
    margin-top: auto;
}

.footer p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* =============================================
   Admin Panel
   ============================================= */
.admin-container {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
    min-height: calc(100vh - 200px);
}

.admin-sidebar {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    height: fit-content;
    border: 1px solid var(--border-color);
}

.admin-nav {
    list-style: none;
}

.admin-nav li {
    margin-bottom: 0.5rem;
}

.admin-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: var(--transition);
}

.admin-nav a:hover,
.admin-nav a.active {
    background: var(--gradient-primary);
    color: white;
}

.admin-content {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 2rem;
    border: 1px solid var(--border-color);
}

/* =============================================
   Statistics Cards - Animated
   ============================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-input);
    border-radius: var(--radius-xl);
    padding: 2rem;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-value {
    font-size: 3rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

/* =============================================
   Tables - Modern Dark Style
   ============================================= */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 1rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background: var(--bg-input);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.table tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

.table tr:last-child td {
    border-bottom: none;
}

/* =============================================
   Alerts - Modern Style
   ============================================= */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--success);
    color: var(--success);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid var(--warning);
    color: var(--warning);
}

/* =============================================
   Login Page - Centered Card
   ============================================= */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--gradient-dark);
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 3rem;
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border-color);
}

.login-card h2 {
    text-align: center;
    margin-bottom: 2rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.8rem;
}

/* =============================================
   Hidden Elements
   ============================================= */
.hidden {
    display: none !important;
}

/* =============================================
   Loading Spinner - Animated
   ============================================= */
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =============================================
   Animations
   ============================================= */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.card, .tab-btn, .qr-type-btn, .stat-card {
    animation: fadeIn 0.5s ease forwards;
}

/* =============================================
   Responsive Design
   ============================================= */
@media (max-width: 768px) {
    .header-container {
        flex-wrap: wrap;
    }
    
    .header-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        padding-top: 1rem;
        gap: 0.5rem;
    }
    
    .header-nav.active {
        display: flex;
    }
    
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .hero h2 {
        font-size: 2rem;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        width: 100%;
        justify-content: center;
    }
    
    .qr-type-selector {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .admin-container {
        grid-template-columns: 1fr;
    }
    
    .admin-sidebar {
        order: -1;
    }
    
    .admin-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .admin-nav li {
        margin: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card .stat-value {
        font-size: 2.5rem;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 1.5rem;
        border-radius: var(--radius-lg);
    }
    
    .qr-type-selector {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .qr-type-btn {
        padding: 1rem 0.5rem;
    }
    
    .qr-type-btn svg {
        width: 24px;
        height: 24px;
    }
    
    .qr-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* =============================================
   Selection Style
   ============================================= */
::selection {
    background: var(--primary);
    color: white;
}

/* =============================================
   Scrollbar Style
   ============================================= */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}