/* 
    Ultra-Premium Minimalist SaaS Theme 
    Designed by: Mohammed Amir Al-Zawfi
*/

:root {
    /* Color Palette - Clean & Bright */
    --bg-main: #f8fafc; /* Very light slate for main bg */
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-secondary: #64748b;
    --primary: #0ea5e9; /* Professional vibrant blue */
    --primary-hover: #0284c7;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    /* Borders & Shadows */
    --border-light: rgba(15, 23, 42, 0.08);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-secondary: #94a3b8;
    --border-light: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

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

body {
    font-family: 'Tajawal', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background Patterns (Subtle Grid) */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: linear-gradient(var(--border-light) 1px, transparent 1px),
                      linear-gradient(90deg, var(--border-light) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.3;
    z-index: -1;
    pointer-events: none;
}

/* Utility Classes */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-secondary { color: var(--text-secondary); }
.mb-4 { margin-bottom: 1.5rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* Panels & Cards */
.glass-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.glass-panel:hover {
    box-shadow: var(--shadow-md);
}

/* Typography */
h1, h2, h3, h4 {
    font-family: 'Outfit', 'Tajawal', sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.accent-text {
    color: var(--primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.code-font {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.9em;
    letter-spacing: 0.5px;
    background: #f1f5f9;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    color: var(--text-main);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn i { font-size: 1.25rem; }

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.3);
}

.btn-outline {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-light);
}

.btn-outline:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

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

.btn-ghost:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.btn-icon {
    padding: 0.5rem;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.btn-icon.text-danger:hover {
    background: #fee2e2;
    color: var(--danger);
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

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

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge.active { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.badge.expired { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.badge.trial { background: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; }
.badge.pending { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

.notification-badge {
    background: var(--danger);
    color: white;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    margin-right: auto;
    border: none;
}

/* Form Elements */
.modern-form .input-group {
    margin-bottom: 1.25rem;
}

.modern-form label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.95rem;
}

.modern-form label i {
    color: var(--primary);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
    background: white;
}

.input-wrapper i {
    position: absolute;
    right: 1rem;
    color: var(--text-secondary);
    font-size: 1.2rem;
}

.input-wrapper input,
.input-wrapper select {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 2.8rem;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
}

/* Main Layout */
.screen {
    display: none;
    min-height: 100vh;
}
.screen.active {
    display: flex;
}

/* Login Screen */
#login-screen {
    justify-content: center;
    align-items: center;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
}

.login-card {
    padding: 2.5rem 2rem;
}

.brand-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-circle {
    width: 70px;
    height: 70px;
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 2rem;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.login-btn {
    width: 100%;
    margin-top: 1rem;
}

.error-msg {
    color: var(--danger);
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
    min-height: 20px;
}

/* App Layout */
#app-screen {
    background: var(--bg-main);
}

.sidebar {
    width: 280px;
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border-left: 1px solid var(--border-light);
    border-top: none;
    border-bottom: none;
    background: var(--bg-card);
    z-index: 100;
}

.sidebar-brand {
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

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

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.nav-item i {
    font-size: 1.3rem;
}

.nav-item:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(14, 165, 233, 0.2);
}

.sidebar-footer {
    padding: 1.5rem 1rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 40px;
    height: 40px;
    background: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.2rem;
}

.admin-info {
    display: flex;
    flex-direction: column;
}

.admin-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
}

.admin-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: calc(100vw - 280px);
}

.topbar {
    height: 80px;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 0;
    border-bottom: 1px solid var(--border-light);
    border-top: none;
    border-right: none;
    border-left: none;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 90;
}

.topbar-search {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: 20px;
    padding: 0.5rem 1rem;
    width: 300px;
    border: 1px solid transparent;
    transition: var(--transition);
}

.topbar-search:focus-within {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.topbar-search i {
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

.topbar-search input {
    border: none;
    background: transparent;
    outline: none;
    color: var(--text-main);
    width: 100%;
    font-family: inherit;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Views Container */
.views-container {
    padding: 2rem;
    flex: 1;
    overflow-y: auto;
}

.view-pane {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.view-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    margin-bottom: 2rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

.primary-bg { background: #e0f2fe; color: var(--primary); }
.success-bg { background: #dcfce7; color: var(--success); }
.warning-bg { background: #fef3c7; color: var(--warning); }
.info-bg { background: #f3e8ff; color: #a855f7; }

.stat-info h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
}

/* Charts */
.dashboard-charts {
    margin-bottom: 2rem;
}

.chart-container {
    padding: 1.5rem;
}

.canvas-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
    margin-top: 1rem;
}

/* Tables */
.data-table-card {
    padding: 1.5rem;
    background: var(--bg-card);
}

.table-actions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.search-box {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    width: 300px;
    border: 1px solid transparent;
}
.search-box:focus-within {
    background: white;
    border-color: var(--primary);
}
.search-box input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-family: inherit;
    margin-right: 0.5rem;
}
.search-box i {
    color: var(--text-secondary);
}

.table-responsive {
    overflow-x: auto;
}

.modern-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: right;
}

.modern-table th {
    padding: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-light);
}

.modern-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-main);
    font-size: 0.95rem;
    vertical-align: middle;
}

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

.modern-table tbody tr {
    transition: var(--transition);
}

.modern-table tbody tr:hover {
    background: #f8fafc;
}

/* Specific elements inside tables */
.code-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f1f5f9;
    padding: 0.3rem 0.5rem 0.3rem 0.8rem;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.9em;
    width: max-content;
}

.copy-btn {
    background: transparent;
    border: none;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem;
    border-radius: 4px;
}
.copy-btn:hover {
    background: #e0f2fe;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    background: var(--bg-card);
}

.slide-up {
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .slide-up {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.modal-header h3 i {
    color: var(--primary);
}

.row-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 9999;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    color: var(--text-main);
    font-weight: 600;
    animation: slideInLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.toast i { font-size: 1.5rem; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.info i { color: var(--primary); }

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-50px); }
    to { opacity: 1; transform: translateX(0); }
}
