/* Comprehensive Responsive Design Framework */

/* CSS Variables for Consistency */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    
    --sidebar-width: 16rem;
    --header-height: 4rem;
    --border-radius: 0.5rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --transition: all 0.3s ease;
    
    --text-dark: #1a202c;
    --text-muted: #6c757d;
    --bg-light: #f8f9fa;
    --border-color: #dee2e6;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Tajawal', 'Cairo', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.5;
    direction: rtl;
    overflow-x: hidden;
}

/* Typography Scale */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }
h5 { font-size: 0.875rem; }
h6 { font-size: 0.75rem; }

@media (min-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.125rem; }
}

/* Layout Components */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    z-index: 1000;
    overflow-y: auto;
    transition: var(--transition);
    transform: translateX(100%);
}

.sidebar.show {
    transform: translateX(0);
}

@media (min-width: 992px) {
    .sidebar {
        transform: translateX(0);
    }
}

.main-content {
    margin-right: 0;
    min-height: 100vh;
    background-color: var(--bg-light);
    padding: 1rem;
    transition: var(--transition);
}

@media (min-width: 992px) {
    .main-content {
        margin-right: var(--sidebar-width);
        padding: 1.5rem;
    }
}

/* Mobile Navigation */
.mobile-nav-toggle {
    display: flex;
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
}

.mobile-nav-toggle:hover {
    background: var(--secondary-color);
    transform: scale(1.05);
}

@media (min-width: 992px) {
    .mobile-nav-toggle {
        display: none;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar.show ~ .sidebar-overlay {
    display: block;
}

/* Header */
.main-header {
    background: white;
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--box-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .main-header {
        padding: 1.25rem;
        margin-bottom: 1.5rem;
        flex-wrap: nowrap;
    }
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
    flex: 1;
}

@media (min-width: 576px) {
    .page-title {
        font-size: 1.5rem;
    }
}

@media (min-width: 768px) {
    .page-title {
        font-size: 2rem;
    }
}

/* Cards */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 1rem;
    background: white;
    transition: var(--transition);
}

.card:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

.card-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    padding: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 1rem;
}

@media (min-width: 768px) {
    .card {
        margin-bottom: 1.5rem;
    }
    
    .card-header,
    .card-body {
        padding: 1.25rem;
    }
}

/* Stats Cards */
.stats-card {
    background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
    color: white;
    padding: 1.25rem;
    border-radius: var(--border-radius);
    text-align: center;
    margin-bottom: 1rem;
    box-shadow: 0 0.25rem 1rem rgba(108, 92, 231, 0.3);
    transition: var(--transition);
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stats-card:hover {
    transform: translateY(-2px);
}

.stats-value {
    font-size: 1.75rem;
    font-weight: 700;
    display: block;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.stats-label {
    font-size: 0.8rem;
    opacity: 0.9;
    line-height: 1.3;
}

@media (min-width: 576px) {
    .stats-card {
        padding: 1.5rem;
        min-height: 140px;
    }
    
    .stats-value {
        font-size: 2.25rem;
        margin-bottom: 0.625rem;
    }
    
    .stats-label {
        font-size: 0.9rem;
    }
}

@media (min-width: 768px) {
    .stats-card {
        padding: 1.875rem;
        margin-bottom: 1.25rem;
        min-height: 160px;
    }
    
    .stats-value {
        font-size: 3rem;
        margin-bottom: 0.625rem;
    }
    
    .stats-label {
        font-size: 1rem;
    }
}

/* Tables */
.table-responsive {
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 1rem;
    background: white;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    background: white;
    margin-bottom: 0;
    font-size: 0.8rem;
    white-space: nowrap;
}

.table thead th {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    font-weight: 600;
    padding: 0.75rem;
    font-size: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table tbody td {
    vertical-align: middle;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-dark);
    font-size: 0.8rem;
}

@media (min-width: 576px) {
    .table {
        font-size: 0.875rem;
    }
    
    .table thead th {
        padding: 1rem;
        font-size: 0.8rem;
    }
    
    .table tbody td {
        padding: 1rem;
        font-size: 0.875rem;
    }
}

@media (min-width: 768px) {
    .table thead th {
        padding: 0.9375rem;
        font-size: 0.875rem;
    }
    
    .table tbody td {
        padding: 0.9375rem;
    }
    
    .table {
        white-space: normal;
    }
}

/* Forms */
.form-control, .form-select {
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    background-color: white;
    color: var(--text-dark);
    font-size: 1rem;
    transition: var(--transition);
    width: 100%;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.125rem rgba(102, 126, 234, 0.25);
    background-color: white;
    color: var(--text-dark);
    outline: none;
}

.form-label {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    display: block;
}

.form-floating .form-control {
    padding: 1rem 0.75rem;
}

@media (max-width: 767px) {
    .form-control, .form-select {
        font-size: 1rem;
    }
}

/* Buttons */
.btn {
    border-radius: var(--border-radius);
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

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

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

.btn-warning {
    background: var(--warning-color);
    color: var(--text-dark);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

@media (min-width: 576px) {
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.9375rem;
    }
}

/* Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-left: -0.375rem;
    margin-right: -0.375rem;
}

.row > * {
    padding-left: 0.375rem;
    padding-right: 0.375rem;
    flex: 1 1 auto;
}

@media (min-width: 576px) {
    .row {
        margin-left: -0.75rem;
        margin-right: -0.75rem;
    }
    
    .row > * {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

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

@media (min-width: 576px) {
    .col-sm-1 { flex: 0 0 auto; width: 8.333333%; }
    .col-sm-2 { flex: 0 0 auto; width: 16.666667%; }
    .col-sm-3 { flex: 0 0 auto; width: 25%; }
    .col-sm-4 { flex: 0 0 auto; width: 33.333333%; }
    .col-sm-5 { flex: 0 0 auto; width: 41.666667%; }
    .col-sm-6 { flex: 0 0 auto; width: 50%; }
    .col-sm-7 { flex: 0 0 auto; width: 58.333333%; }
    .col-sm-8 { flex: 0 0 auto; width: 66.666667%; }
    .col-sm-9 { flex: 0 0 auto; width: 75%; }
    .col-sm-10 { flex: 0 0 auto; width: 83.333333%; }
    .col-sm-11 { flex: 0 0 auto; width: 91.666667%; }
    .col-sm-12 { flex: 0 0 auto; width: 100%; }
}

@media (min-width: 768px) {
    .col-md-1 { flex: 0 0 auto; width: 8.333333%; }
    .col-md-2 { flex: 0 0 auto; width: 16.666667%; }
    .col-md-3 { flex: 0 0 auto; width: 25%; }
    .col-md-4 { flex: 0 0 auto; width: 33.333333%; }
    .col-md-5 { flex: 0 0 auto; width: 41.666667%; }
    .col-md-6 { flex: 0 0 auto; width: 50%; }
    .col-md-7 { flex: 0 0 auto; width: 58.333333%; }
    .col-md-8 { flex: 0 0 auto; width: 66.666667%; }
    .col-md-9 { flex: 0 0 auto; width: 75%; }
    .col-md-10 { flex: 0 0 auto; width: 83.333333%; }
    .col-md-11 { flex: 0 0 auto; width: 91.666667%; }
    .col-md-12 { flex: 0 0 auto; width: 100%; }
}

@media (min-width: 992px) {
    .col-lg-1 { flex: 0 0 auto; width: 8.333333%; }
    .col-lg-2 { flex: 0 0 auto; width: 16.666667%; }
    .col-lg-3 { flex: 0 0 auto; width: 25%; }
    .col-lg-4 { flex: 0 0 auto; width: 33.333333%; }
    .col-lg-5 { flex: 0 0 auto; width: 41.666667%; }
    .col-lg-6 { flex: 0 0 auto; width: 50%; }
    .col-lg-7 { flex: 0 0 auto; width: 58.333333%; }
    .col-lg-8 { flex: 0 0 auto; width: 66.666667%; }
    .col-lg-9 { flex: 0 0 auto; width: 75%; }
    .col-lg-10 { flex: 0 0 auto; width: 83.333333%; }
    .col-lg-11 { flex: 0 0 auto; width: 91.666667%; }
    .col-lg-12 { flex: 0 0 auto; width: 100%; }
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.status-created { background: #e3f2fd; color: #1976d2; }
.status-processing { background: #fff3e0; color: #f57c00; }
.status-shipping { background: #e8f5e8; color: #388e3c; }
.status-delivered { background: #e8f5e8; color: #2e7d32; }
.status-cancelled { background: #ffebee; color: #d32f2f; }

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

@media (min-width: 576px) {
    .d-sm-none { display: none !important; }
    .d-sm-block { display: block !important; }
    .d-sm-flex { display: flex !important; }
}

@media (min-width: 768px) {
    .d-md-none { display: none !important; }
    .d-md-block { display: block !important; }
    .d-md-flex { display: flex !important; }
}

@media (min-width: 992px) {
    .d-lg-none { display: none !important; }
    .d-lg-block { display: block !important; }
    .d-lg-flex { display: flex !important; }
}

/* Spacing Utilities */
.m-0 { margin: 0 !important; }
.m-1 { margin: 0.25rem !important; }
.m-2 { margin: 0.5rem !important; }
.m-3 { margin: 1rem !important; }
.m-4 { margin: 1.5rem !important; }
.m-5 { margin: 3rem !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.p-5 { padding: 3rem !important; }

.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }

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

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fw-bold { font-weight: 700 !important; }
.fw-normal { font-weight: 400 !important; }
.fw-light { font-weight: 300 !important; }

/* Responsive breakpoints for mobile content */
@media (max-width: 991px) {
    .main-content {
        padding-top: 4rem;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 1rem 0.75rem;
        padding-top: 4rem;
    }
    
    .table-responsive {
        border-radius: 0;
        margin-left: -0.75rem;
        margin-right: -0.75rem;
    }
    
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

@media (max-width: 576px) {
    .main-content {
        padding: 0.75rem 0.5rem;
        padding-top: 4rem;
    }
    
    .container-fluid {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
    
    .card {
        border-radius: var(--border-radius);
        margin-bottom: 0.75rem;
    }
    
    .row {
        margin-left: -0.25rem;
        margin-right: -0.25rem;
    }
    
    .row > * {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
}

/* Login Page Responsive */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 2rem;
}

@media (max-width: 576px) {
    .login-card {
        padding: 1.5rem;
        margin: 1rem;
    }
}

/* Animation and transitions */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

/* Print styles */
@media print {
    .sidebar,
    .mobile-nav-toggle,
    .main-header {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .table {
        font-size: 0.75rem;
    }
}