:root {
    --primary-color: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary-color: #ec4899;
    --bg-color: #f3f4f6;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --font-family: 'Tajawal', sans-serif;
}

[data-theme="dark"] {
    --bg-color: #111827;
    --sidebar-bg: #1f2937;
    --card-bg: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --border-color: #374151;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    direction: rtl;
    min-height: 100vh;
    overflow-x: hidden;
    /* App-like feel */
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: width 0.3s ease;
}

.sidebar .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 3rem;
}

.nav-links {
    list-style: none;
    flex: 1;
}

.nav-links li {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-weight: 500;
}

.nav-links li:hover {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.nav-links li.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-md);
}

.nav-links li i {
    font-size: 1.25rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.user-avatar {
    width: 40px;
    height: 40px;
    background-color: var(--primary-light);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-details .name {
    font-weight: 700;
    font-size: 0.9rem;
}

.user-details .role {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: 70px;
    background-color: var(--sidebar-bg);
    /* Or transparent */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    border-bottom: 1px solid var(--border-color);
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: var(--bg-color);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    width: 300px;
}

.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    font-family: inherit;
    width: 100%;
    color: var(--text-primary);
}

.actions {
    display: flex;
    gap: 1rem;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.icon-btn:hover {
    color: var(--primary-color);
}

.view-container {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* Base Styles for Views */
h2 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: transform 0.1s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.w-full {
    width: 100%;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.p-4 {
    padding: 1rem;
}

.p-2 {
    padding: 0.5rem;
}

/* Utilities */
.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.flex-1 {
    flex: 1;
}

.text-xs {
    font-size: 0.75rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-xl {
    font-size: 1.25rem;
}

.text-2xl {
    font-size: 1.5rem;
}

.text-6xl {
    font-size: 3.75rem;
}

.font-bold {
    font-weight: 700;
}

.text-red-500 {
    color: #ef4444;
}

.text-gray-500 {
    color: #6b7280;
}

.text-gray-400 {
    color: #9ca3af;
}

.text-primary {
    color: var(--primary-color);
}

.bg-gray-100 {
    background-color: #f3f4f6;
}

.bg-white {
    background-color: white;
}

.cursor-pointer {
    cursor: pointer;
}

.rounded {
    border-radius: var(--radius-md);
}

.border {
    border: 1px solid var(--border-color);
}

.border-b {
    border-bottom: 1px solid var(--border-color);
}

.border-t {
    border-top: 1px solid var(--border-color);
}

/* Dashboard Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Global Models */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--card-bg);
    width: 500px;
    max-width: 90%;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.premium-modal {
    width: 700px;
    max-width: 95%;
    padding: 2rem;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.95);
    opacity: 0;
    animation: modalPopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

[data-theme="dark"] .premium-modal {
    background: rgba(31, 41, 55, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

@keyframes modalPopIn {
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.premium-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.premium-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.close-btn {
    background: var(--bg-color);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #fee2e2;
    color: #ef4444;
    transform: rotate(90deg);
}

.custom-scrollbar {
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 0.5rem;
    margin-top: 1.5rem;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.form-section {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.last-section {
    margin-bottom: 0;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title i {
    color: var(--primary-color);
}

.img-upload-box {
    width: 140px;
    height: 140px;
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: white;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .img-upload-box {
    background: var(--sidebar-bg);
    border-color: var(--border-color);
}

.img-upload-box:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-secondary);
}

.upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.img-upload-box:hover .upload-overlay {
    opacity: 1;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i {
    position: absolute;
    right: 1rem;
    color: var(--text-secondary);
    font-size: 1.2rem;
}

.premium-input {
    padding-right: 2.8rem;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: white;
    height: 48px;
    transition: all 0.3s;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.02);
}

.premium-textarea {
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: white;
    transition: all 0.3s;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .premium-input, [data-theme="dark"] .premium-textarea {
    background: var(--sidebar-bg);
    border-color: var(--border-color);
}

.premium-input:focus, .premium-textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.currency-label {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
}

.text-left {
    text-align: left;
    padding-left: 3rem;
}

.sizes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 0.75rem;
}

.size-box {
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
}

[data-theme="dark"] .size-box {
    background: var(--sidebar-bg);
    border-color: var(--border-color);
}

.size-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.size-label {
    background: #f8fafc;
    text-align: center;
    padding: 0.25rem;
    font-weight: 700;
    font-size: 0.85rem;
    border-bottom: 1px solid #cbd5e1;
    color: var(--text-secondary);
}

[data-theme="dark"] .size-label {
    background: rgba(0, 0, 0, 0.2);
    border-color: var(--border-color);
}

.size-input-field {
    width: 100%;
    border: none;
    text-align: center;
    padding: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    background: transparent;
    color: var(--text-primary);
    outline: none;
}

.standard-size {
    border-color: var(--primary-light);
}

.bg-primary-light {
    background: var(--primary-light) !important;
}

.border-primary-light {
    border-color: var(--primary-light) !important;
}

.profit-indicator {
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    border: 1px solid #cbd5e1;
    transition: all 0.3s;
}

[data-theme="dark"] .profit-indicator {
    background: var(--sidebar-bg);
    border-color: var(--border-color);
}

.profit-indicator.positive {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}

.profit-indicator.negative {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}

[data-theme="dark"] .profit-indicator.positive {
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
}

[data-theme="dark"] .profit-indicator.negative {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
}

.premium-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.btn-glass {
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    backdrop-filter: blur(8px);
}

.btn-glass:hover {
    background: white;
    color: var(--text-primary);
}

[data-theme="dark"] .btn-glass {
    background: rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .btn-glass:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-gradient {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    transition: all 0.3s;
}

.btn-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.grid-sizes {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.size-input {
    text-align: center;
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        right: -260px;
        top: 0;
        height: 100%;
        z-index: 1000;
        box-shadow: 0 0 15px rgba(0,0,0,0.1);
    }
    
    .mobile-menu-btn {
        display: block !important;
    }

    .sidebar.active {
        right: 0;
    }

    .main-content {
        margin-right: 0;
    }

    .modal-content {
        width: 95%;
        margin: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Stack flex containers in forms */
    .form-row-responsive {
        flex-direction: column !important;
        gap: 1rem;
    }

    .w-responsive-full {
        width: 100% !important;
        flex: none !important;
    }

    /* Adjust grid sizes for mobile */
    .grid-sizes {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Status Colors */
.bg-green-50,
.bg-green-50 td {
    background-color: #f0fdf4 !important;
}

.bg-red-50,
.bg-red-50 td {
    background-color: #fef2f2 !important;
}

.bg-yellow-50,
.bg-yellow-50 td {
    background-color: #fffbeb !important;
}

.bg-green-100 {
    background-color: #dcfce7 !important;
}

.bg-red-100 {
    background-color: #fee2e2 !important;
}

.bg-yellow-100 {
    background-color: #fef3c7 !important;
}

.bg-green-500 {
    background-color: #22c55e !important;
}

.bg-red-500 {
    background-color: #ef4444 !important;
}

.text-green-700 {
    color: #15803d !important;
}

.text-red-700 {
    color: #b91c1c !important;
}

.text-yellow-700 {
    color: #a16207 !important;
}

.text-green-500 {
    color: #22c55e !important;
}

.text-yellow-500 {
    color: #f59e0b !important;
}

/* Print Styles */
@media print {
    body {
        overflow: visible !important;
        height: auto !important;
        background: white !important;
    }

    .app-container,
    .modal-backdrop,
    #modal-container,
    .sidebar,
    .top-bar,
    .no-print {
        display: none !important;
    }

    #receipt-print-area {
        display: block !important;
        position: static !important;
        width: 100% !important;
        padding: 5mm !important;
        visibility: visible !important;
        direction: rtl !important;
    }

    #receipt-print-area * {
        visibility: visible !important;
    }
}

/* Receipt styles (hidden during normal view) */
#receipt-print-area {
    display: none;
}

/* WhatsApp Button */
.whatsapp-btn { display: flex; align-items: center; justify-content: center; gap: 0.5rem; background-color: #25D366; color: white; text-decoration: none; padding: 0.75rem 1.5rem; border-radius: 9999px; font-weight: 700; font-size: 1rem; transition: all 0.3s ease; border: none; box-shadow: 0 4px 6px -1px rgba(37, 211, 102, 0.3); margin-top: 1.5rem; cursor: pointer; }
.whatsapp-btn:hover { background-color: #128C7E; transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(37, 211, 102, 0.4); color: white; }
.whatsapp-btn i { font-size: 1.25rem; }
