/* ==========================================
   Athdak Admin Panel - Styles
   RTL Arabic Interface | Dark Theme
   ========================================== */

:root {
    --primary: #6C63FF;
    --primary-dark: #5a52e0;
    --secondary: #00D9FF;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;

    --bg-dark: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-surface: #252540;
    --bg-hover: #2a2a4a;

    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6b6b80;

    --border: #2a2a4a;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    direction: rtl;
}

/* ==========================================
   Login Screen
   ========================================== */

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a3a 100%);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    padding: 48px;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 420px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.login-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 36px;
    color: white;
}

.login-card h1 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.input-group {
    position: relative;
    margin-bottom: 16px;
}

.input-group i {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    padding: 16px 48px 16px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    transition: all 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.2);
}

.btn-primary {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
    margin-top: 8px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(108, 99, 255, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    padding: 12px 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-top: 16px;
    font-size: 14px;
}

/* ==========================================
   Main Layout
   ========================================== */

.main-app {
    display: flex;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header .logo {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.sidebar-header .logo-text h2 {
    font-size: 20px;
    font-weight: 800;
}

.sidebar-header .logo-text span {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s;
    text-align: right;
    width: 100%;
}

.nav-item i {
    width: 24px;
    text-align: center;
    font-size: 18px;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.2) 0%, rgba(0, 217, 255, 0.1) 100%);
    color: var(--primary);
    border-right: 3px solid var(--primary);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: none;
    border-radius: var(--radius-md);
    color: var(--danger);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

.logout-btn:hover {
    background: var(--danger);
    color: white;
}

/* Content Area */
.content {
    flex: 1;
    margin-right: 280px;
    display: flex;
    flex-direction: column;
}

.content-header {
    background: var(--bg-card);
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.content-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

#currentUser {
    color: var(--text-secondary);
    font-size: 14px;
}

.content-body {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* ==========================================
   Sections
   ========================================== */

.section {
    display: none;
}

.section.active {
    display: block;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 20px;
    font-weight: 700;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-card.purple .stat-icon {
    background: rgba(108, 99, 255, 0.15);
    color: var(--primary);
}

.stat-card.blue .stat-icon {
    background: rgba(0, 217, 255, 0.15);
    color: var(--secondary);
}

.stat-card.green .stat-icon {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.stat-card.orange .stat-icon {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.stat-info h3 {
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* Cards */
.dashboard-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card h3 {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card h3 i {
    color: var(--primary);
}

.activity-list {
    padding: 16px 24px;
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.activity-icon.purple {
    background: rgba(108, 99, 255, 0.15);
    color: var(--primary);
}

.activity-icon.green {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.activity-text {
    flex: 1;
}

.activity-text p {
    font-size: 14px;
    font-weight: 600;
}

.activity-text span {
    font-size: 12px;
    color: var(--text-muted);
}

/* ==========================================
   Tables
   ========================================== */

.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filters select {
    padding: 10px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
}

.filters select:focus {
    outline: none;
    border-color: var(--primary);
}

.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: var(--bg-surface);
    padding: 16px 20px;
    text-align: right;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 16px 20px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:hover {
    background: var(--bg-hover);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table .loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.data-table .loading i {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge.green {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.badge.yellow {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.badge.red {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.badge.purple {
    background: rgba(108, 99, 255, 0.15);
    color: var(--primary);
}

.badge.blue {
    background: rgba(0, 217, 255, 0.15);
    color: var(--secondary);
}

/* Action Buttons */
.action-btns {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.action-btn.edit {
    background: rgba(108, 99, 255, 0.15);
    color: var(--primary);
}

.action-btn.edit:hover {
    background: var(--primary);
    color: white;
}

.action-btn.delete {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.action-btn.delete:hover {
    background: var(--danger);
    color: white;
}

/* Search Box */
.search-box {
    position: relative;
    width: 300px;
}

.search-box i {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 12px 44px 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.product-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.3s;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.product-image {
    height: 160px;
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-info {
    padding: 16px;
}

.product-info h4 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.product-info p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.product-price {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary);
}

.product-price span {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

/* ==========================================
   Modals
   ========================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    animation: modalSlide 0.3s ease;
}

.modal-content.large {
    max-width: 680px;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.close-btn:hover {
    background: var(--danger);
    color: white;
}

.modal form {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.2);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 12px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.checkbox-group {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-top: 30px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 14px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.option-row input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: var(--success);
}

.option-row input[type="text"] {
    flex: 1;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.modal-footer .btn-primary {
    width: auto;
    padding: 12px 32px;
}

/* ==========================================
   Toast Notification
   ========================================== */

.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    border: 1px solid var(--success);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 2000;
    transition: all 0.4s ease;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast i {
    color: var(--success);
    font-size: 20px;
}

.toast.error {
    border-color: var(--danger);
}

.toast.error i {
    color: var(--danger);
}

/* ==========================================
   Responsive
   ========================================== */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(100%);
        transition: transform 0.3s;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content {
        margin-right: 0;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .search-box {
        width: 100%;
    }

    .section-header {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }
}

/* Loading Animation */
.loading {
    color: var(--text-muted);
    padding: 40px;
    text-align: center;
}

.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Text Utilities */
.text-truncate {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ==========================================
   Charts
   ========================================== */

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    padding: 16px;
    height: 320px;
    display: flex;
    flex-direction: column;
}

.chart-card h3 {
    padding: 0 0 16px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.chart-card canvas {
    flex: 1;
    width: 100% !important;
    height: 100% !important;
}

/* ==========================================
   Notifications
   ========================================== */

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.form-actions button {
    flex: 1;
}

/* ==========================================
   Modals & Import
   ========================================== */

.modal-body {
    padding: 24px;
}

#importData {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 16px;
}

#importData:focus {
    outline: none;
    border-color: var(--primary);
}