/* ===== CSS Variables ===== */
:root {
    --bg-dark: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-input: #252540;
    --bg-hover: #2a2a4a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --accent-blue: #4a6cf7;
    --accent-green: #22c55e;
    --accent-yellow: #eab308;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    --border-color: #2a2a4a;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    direction: rtl;
}

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

/* ===== Pages ===== */
.page {
    display: none;
}

.page.active {
    display: flex;
}

/* ===== Login Page ===== */
#login-page {
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #2a1a4a 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header .logo {
    font-size: 48px;
    margin-bottom: 10px;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header p {
    color: var(--text-secondary);
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.2);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

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

.input-with-btn {
    display: flex;
    gap: 10px;
}

.input-with-btn input {
    flex: 1;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(74, 108, 247, 0.4);
}

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

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.btn-block {
    width: 100%;
}

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

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

/* ===== Error/Success Messages ===== */
.error-message {
    color: var(--accent-red);
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
}

.message {
    padding: 10px;
    border-radius: var(--radius-sm);
    margin-top: 15px;
    text-align: center;
}

.message.success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--accent-green);
}

.message.error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

/* ===== Dashboard Layout ===== */
#dashboard-page {
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header .logo {
    font-size: 28px;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: var(--transition);
    color: var(--text-secondary);
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(74, 108, 247, 0.2), rgba(139, 92, 246, 0.2));
    color: var(--accent-blue);
}

.nav-item .icon {
    font-size: 20px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

/* ===== Main Content ===== */
.main-content {
    margin-right: 260px;
    min-height: 100vh;
    padding: 30px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.search-box input {
    width: 300px;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    color: var(--text-primary);
    font-family: inherit;
}

.user-info {
    color: var(--text-secondary);
}

/* ===== Tab Content ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.tab-header h1 {
    font-size: 24px;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 25px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

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

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.stat-icon.blue { background: rgba(74, 108, 247, 0.2); }
.stat-icon.green { background: rgba(34, 197, 94, 0.2); }
.stat-icon.yellow { background: rgba(234, 179, 8, 0.2); }
.stat-icon.red { background: rgba(239, 68, 68, 0.2); }

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

.stat-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 5px;
}

/* ===== Filters ===== */
.filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.filters input,
.filters select {
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    min-width: 200px;
}

/* ===== Data Table ===== */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

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

.data-table th,
.data-table td {
    padding: 16px 20px;
    text-align: right;
}

.data-table th {
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tr {
    border-bottom: 1px solid var(--border-color);
}

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

.data-table tr:hover {
    background: var(--bg-hover);
}

.data-table td {
    font-size: 14px;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--accent-green);
}

.badge-warning {
    background: rgba(234, 179, 8, 0.2);
    color: var(--accent-yellow);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

.badge-info {
    background: rgba(74, 108, 247, 0.2);
    color: var(--accent-blue);
}

/* Action Buttons */
.action-btns {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.action-btn.edit {
    background: rgba(74, 108, 247, 0.2);
    color: var(--accent-blue);
}

.action-btn.delete {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

.action-btn:hover {
    transform: scale(1.1);
}

/* ===== Settings Card ===== */
.settings-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 30px;
    border: 1px solid var(--border-color);
    max-width: 500px;
    margin-top: 25px;
}

.settings-card h2 {
    margin-bottom: 25px;
    font-size: 18px;
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

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

.modal-header h2 {
    font-size: 18px;
}

.close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-input);
    color: var(--text-secondary);
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-btn:hover {
    background: var(--accent-red);
    color: white;
}

#code-form {
    padding: 25px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 20px;
    margin-top: 10px;
    border-top: 1px solid var(--border-color);
}

/* ===== Code Display ===== */
.code-display {
    font-family: 'Courier New', monospace;
    background: var(--bg-input);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    letter-spacing: 1px;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
    }
    
    .sidebar-header h2,
    .nav-item span:not(.icon),
    .sidebar-footer span:not(.icon) {
        display: none;
    }
    
    .sidebar-header {
        justify-content: center;
    }
    
    .nav-item {
        justify-content: center;
    }
    
    .main-content {
        margin-right: 80px;
    }
}

@media (max-width: 768px) {
    .form-row,
    .form-row.three-cols {
        grid-template-columns: 1fr;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filters input,
    .filters select {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
