/* ============================================================================
   Layout System - نظام التخطيط العام
   متوافق مع هوية نادي أدِيب
   ============================================================================ */

:root {
    /* Layout Dimensions */
    --header-height: 70px;
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 70px;
    
    /* Layout Spacing - قابلة للتحكم من مكان واحد */
    --layout-gap: 0px;                    /* المسافة بين Header و Sidebar/Main */
    --sidebar-main-gap: 0px;              /* المسافة بين Sidebar و Main Content */
    --content-padding: 2rem;              /* Padding داخل Main Content */
    
    /* Z-Index Layers - ترتيب الطبقات */
    --z-header: 900;
    --z-sidebar: 800;
    --z-fab: 999;
    --z-backdrop: 899;
    --z-content: 1;
    
    /* Colors */
    --main-blue: #274060;
    --accent-blue: #3d8fd6;
    --light-blue: #6ba8e2;
    --dark-blue: #1a2a3a;
    --background: linear-gradient(135deg, #f8f9fa 0%, #e6f0f9 100%);
    
    /* Transitions */
    --transition-speed: 0.4s;
    --transition-ease: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ============================================================================
   Global Resets & Base Styles
   ============================================================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--main-blue);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(61, 143, 214, 0.08) 0%, rgba(61, 143, 214, 0) 70%);
    z-index: 0;
    pointer-events: none;
}

/* ============================================================================
   Main Layout Container
   ============================================================================ */

.admin-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
    /* Padding-top = Header Height + Layout Gap */
    padding-top: calc(var(--header-height) + var(--layout-gap));
}

/* ============================================================================
   Header Layout (Fixed Top)
   ============================================================================ */

.admin-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: 900;
}

/* ============================================================================
   Sidebar Layout (Fixed Right - Desktop Only)
   ============================================================================ */

/* Desktop: Sidebar يظهر أسفل Header مباشرة */
@media (min-width: 1025px) {
    .admin-sidebar {
        position: fixed;
        right: 0;
        /* Top = Header Height + Layout Gap */
        top: calc(var(--header-height) + var(--layout-gap));
        width: var(--sidebar-width);
        /* Height = Full Height - Header - Layout Gap */
        height: calc(100vh - var(--header-height) - var(--layout-gap));
        z-index: var(--z-sidebar);
        transition: transform var(--transition-speed) var(--transition-ease),
                    width var(--transition-speed) var(--transition-ease);
    }
}

/* Sidebar Collapsed State - Desktop Only */
@media (min-width: 1025px) {
    .admin-sidebar.collapsed {
        width: var(--sidebar-collapsed-width);
    }
}

/* ============================================================================
   Main Content Area
   ============================================================================ */

.admin-main {
    flex: 1;
    padding: var(--content-padding);
    transition: margin-right var(--transition-speed) var(--transition-ease);
    /* Min-height = Full Height - Header - Layout Gap */
    min-height: calc(100vh - var(--header-height) - var(--layout-gap));
    position: relative;
    z-index: var(--z-content);
}

/* Desktop: Main Content يبتعد عن Sidebar */
@media (min-width: 1025px) {
    .admin-main {
        /* Margin = Sidebar Width + Gap بين Sidebar و Main */
        margin-right: calc(var(--sidebar-width) + var(--sidebar-main-gap));
    }
    
    .admin-sidebar.collapsed ~ .admin-main {
        margin-right: calc(var(--sidebar-collapsed-width) + var(--sidebar-main-gap));
    }
}

/* ============================================================================
   Admin Section (Content Wrapper)
   ============================================================================ */

.admin-section {
    margin-bottom: 2rem;
    animation: fadeInUp 0.5s ease-out;
}

.admin-section.d-none {
    display: none;
}

/* ============================================================================
   Section Header
   ============================================================================ */

.section-header {
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.9) 100%);
    border-radius: 12px;
    border: 1px solid rgba(61, 143, 214, 0.1);
    box-shadow: 0 2px 8px rgba(39, 64, 96, 0.06);
}

.section-header-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 200px;
}

/* العنوان والوصف على اليمين */
.section-header > h1,
.section-header > .section-header-content {
    order: 1;
    margin-left: auto;
}

/* الأزرار على اليسار */
.section-header > .section-header-actions,
.section-header > .section-actions,
.section-header > .btn,
.section-header > button {
    order: 2;
    margin-right: auto;
    margin-left: 0;
}

/* جعل section-subtitle تحت h1 مباشرة */
.section-header > h1 + .section-subtitle {
    width: 100%;
    flex-basis: 100%;
    order: 1;
    margin-top: 0;
    margin-bottom: 0;
}

.section-header h1 {
    font-size: 1.75rem;
    color: var(--main-blue);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    line-height: 1.3;
}

.section-header h1 i {
    color: var(--accent-blue);
    font-size: 1.5rem;
    background: linear-gradient(135deg, rgba(61, 143, 214, 0.15) 0%, rgba(61, 143, 214, 0.08) 100%);
    padding: 0.5rem;
    border-radius: 10px;
}

.section-subtitle {
    color: #64748b;
    font-size: 0.9rem;
    margin: 0;
    padding-right: 0.25rem;
}

.section-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .section-header {
        padding: 1rem;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .section-header > h1,
    .section-header > .section-header-content {
        margin-left: 0;
        width: 100%;
        align-items: center;
    }
    
    .section-header > .section-header-actions,
    .section-header > .section-actions,
    .section-header > .btn,
    .section-header > button {
        margin-right: 0;
        justify-content: center;
        width: 100%;
    }
    
    .section-header h1 {
        font-size: 1.4rem;
        width: 100%;
        text-align: center;
        justify-content: center;
    }
    
    .section-header h1 i {
        font-size: 1.2rem;
        padding: 0.4rem;
    }
    
    .section-header-actions {
        justify-content: center;
        margin-top: 0.5rem;
    }
}


/* ============================================================================
   Grid System
   ============================================================================ */

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -0.75rem;
}

.col {
    flex: 1;
    padding: 0 0.75rem;
}

.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* ============================================================================
   Utility Classes
   ============================================================================ */

/* Display */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }
.d-inline-flex { display: inline-flex !important; }

/* Flexbox */
.flex-column { flex-direction: column !important; }
.flex-row { flex-direction: row !important; }
.align-items-center { align-items: center !important; }
.align-items-start { align-items: flex-start !important; }
.align-items-end { align-items: flex-end !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-around { justify-content: space-around !important; }
.justify-content-end { justify-content: flex-end !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-1 { flex: 1 !important; }

/* Gaps */
.gap-4 { gap: 0.25rem !important; }
.gap-8 { gap: 0.5rem !important; }
.gap-12 { gap: 0.75rem !important; }
.gap-16 { gap: 1rem !important; }
.gap-20 { gap: 1.25rem !important; }
.gap-24 { gap: 1.5rem !important; }
.gap-1-5rem { gap: 1.5rem !important; }
.gap-2rem { gap: 2rem !important; }

/* Margins */
.m-0 { margin: 0 !important; }
.mt-1 { margin-top: 0.5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.mt-4 { margin-top: 2rem !important; }
.mb-1 { margin-bottom: 0.5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.mb-4 { margin-bottom: 2rem !important; }
.mb-2rem { margin-bottom: 2rem !important; }
.ml-auto { margin-left: auto !important; }
.mr-auto { margin-right: auto !important; }

/* Padding */
.p-0 { padding: 0 !important; }
.p-1 { padding: 0.5rem !important; }
.p-2 { padding: 1rem !important; }
.p-3 { padding: 1.5rem !important; }
.p-4 { padding: 2rem !important; }

/* Text Alignment */
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

/* Font Weight */
.fw-normal { font-weight: 400 !important; }
.fw-medium { font-weight: 500 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }

/* Colors */
.text-primary { color: var(--accent-blue) !important; }
.text-secondary { color: #64748b !important; }
.text-success { color: #10b981 !important; }
.text-danger { color: #ef4444 !important; }
.text-warning { color: #f59e0b !important; }

/* Background Colors */
.bg-white { background-color: white !important; }
.bg-light { background-color: #f8f9fa !important; }

/* ============================================================================
   Responsive Breakpoints
   ============================================================================ */

@media (max-width: 1024px) {
    .admin-sidebar {
        transform: translateX(100%);
    }

    .admin-sidebar.active {
        transform: translateX(0);
    }

    .admin-main {
        margin-right: 0;
    }

    .admin-sidebar.collapsed ~ .admin-main {
        margin-right: 0;
    }
}

@media (max-width: 768px) {
    .admin-main {
        padding: 1.5rem;
    }

    .section-header h1 {
        font-size: 1.5rem;
    }

    .section-header h1 i {
        font-size: 1.4rem;
    }

    /* Grid System Responsive */
    .col-1, .col-2, .col-3, .col-4, .col-5, .col-6,
    .col-7, .col-8, .col-9, .col-10, .col-11, .col-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .admin-main {
        padding: 1rem;
    }

    .section-header {
        margin-bottom: 1.5rem;
    }

    .section-header h1 {
        font-size: 1.3rem;
    }
}

/* ============================================================================
   Animations
   ============================================================================ */

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

/* ============================================================================
   Print Styles
   ============================================================================ */

@media print {
    .admin-header,
    .admin-sidebar {
        display: none;
    }

    .admin-main {
        margin-right: 0;
        padding: 0;
    }

    .admin-layout {
        padding-top: 0;
    }
}

/* ============================================================================
   Accessibility
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Visible */
*:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* ============================================================================
   Image Upload Container
   ============================================================================ */

.image-upload-container {
    position: relative;
    width: 100%;
}

.image-upload-container .image-preview {
    width: 100%;
    min-height: 150px;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8fafc;
    color: #64748b;
    overflow: hidden;
}

.image-upload-container .image-preview:hover {
    border-color: var(--main-blue);
    background: rgba(61, 143, 214, 0.05);
    color: var(--main-blue);
}

.image-upload-container .image-preview i {
    font-size: 2rem;
}

.image-upload-container .image-preview img {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 8px;
}

.image-upload-container .image-preview.has-image {
    border-style: solid;
    border-color: #10b981;
    background: #f0fdf4;
}

.image-upload-container .remove-image-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.image-upload-container:hover .remove-image-btn {
    opacity: 1;
}

