/* ===================================
   نظام الدشاديش - CSS الرئيسي
   RTL + Dashboard + Login + CRUD
   =================================== */

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

body {
    font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
    direction: rtl;
    text-align: right;
    background: #f1f5f9;
    color: #1e293b;
    line-height: 1.6;
    min-height: 100vh;
}

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

/* --- Navbar --- */
.navbar {
    background: #1e293b;
    color: #fff;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-brand i { font-size: 1.5rem; color: #60a5fa; }

.navbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #94a3b8;
    font-size: 0.9rem;
}

.btn-logout {
    background: transparent;
    border: 1px solid #475569;
    color: #cbd5e1;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

/* --- Login Page --- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo i { font-size: 3rem; color: #2563eb; margin-bottom: 12px; display: block; }
.login-logo h1 { font-size: 1.5rem; color: #1e293b; margin-bottom: 4px; }
.login-logo p { color: #64748b; font-size: 0.9rem; }

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    direction: rtl;
    transition: border-color 0.2s;
    background: #f8fafc;
}

.form-control:focus {
    outline: none;
    border-color: #2563eb;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

select.form-control { cursor: pointer; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.form-inline-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

.required { color: #dc2626; }

.checkbox-label, .checkbox-label-block {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input, .checkbox-label-block input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.3); }

.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-secondary:hover { background: #cbd5e1; }

.btn-sm { padding: 6px 14px; font-size: 0.85rem; }

.btn-icon, .btn-icon-sm {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-edit { color: #2563eb; }
.btn-edit:hover { background: #eff6ff; }

.btn-delete { color: #dc2626; }
.btn-delete:hover { background: #fef2f2; }

.btn-icon-sm { color: #64748b; font-size: 0.75rem; padding: 2px 4px; }
.btn-icon-sm:hover { color: #2563eb; }

/* --- Alerts --- */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

/* --- Page Layout --- */
.page-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 {
    font-size: 1.4rem;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-header p { color: #64748b; font-size: 0.9rem; margin-top: 2px; }

.page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* --- Cards --- */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 700;
    font-size: 1rem;
    color: #1e293b;
}

.card-body { padding: 20px; }

/* --- Tables --- */
.table-responsive { overflow-x: auto; }

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

.table th, .table td {
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;
}

.table th {
    background: #f8fafc;
    font-weight: 700;
    font-size: 0.85rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover { background: #f8fafc; }

.table code {
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #475569;
}

.text-center { text-align: center; }
.text-muted { color: #94a3b8; }
.text-success { color: #16a34a; }
.text-danger { color: #dc2626; }

.actions-cell {
    display: flex;
    gap: 4px;
}

.price-cell {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: #16a34a; }
.badge-danger { background: #fef2f2; color: #dc2626; }
.badge-info { background: #e0f2fe; color: #0284c7; }

/* --- Stock Badges --- */
.stock-badge {
    display: inline-block;
    min-width: 32px;
    text-align: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
}

.stock-ok { background: #dcfce7; color: #16a34a; }
.stock-zero { background: #fef2f2; color: #dc2626; }

/* --- Color Dot --- */
.color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
    border: 1px solid #d1d5db;
}

/* --- Filters --- */
.filters-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filters-row .form-group {
    min-width: 140px;
    margin-bottom: 0;
}

.filters-row .form-control {
    padding: 8px 12px;
    font-size: 0.9rem;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-card {
    background: #fff;
    border-radius: 16px;
    padding: 28px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-card h3 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* --- Stock Info Cards --- */
.stock-info-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.stock-info-card {
    background: #fff;
    border-radius: 10px;
    padding: 16px 24px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    min-width: 120px;
}

.stock-info-label { font-size: 0.85rem; color: #64748b; margin-bottom: 4px; }
.stock-info-value { font-size: 1.8rem; font-weight: 800; }

/* --- Pagination --- */
.pagination-wrapper {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

.pagination-wrapper nav { display: flex; gap: 4px; }

.pagination-wrapper svg { width: 20px; height: 20px; }

.pagination-wrapper a,
.pagination-wrapper span {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    border: 1px solid #e2e8f0;
}

.pagination-wrapper a { color: #2563eb; background: #fff; }
.pagination-wrapper a:hover { background: #eff6ff; }

.pagination-wrapper span[aria-current] {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* --- Dashboard --- */
.dashboard-header {
    padding: 32px 24px 16px;
    max-width: 1200px;
    margin: 0 auto;
}

.dashboard-header h2 { font-size: 1.6rem; color: #1e293b; margin-bottom: 4px; }
.dashboard-header p { color: #64748b; font-size: 0.95rem; }

.tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    padding: 16px 24px 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.tile {
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.tile::before {
    content: '';
    position: absolute;
    top: 0; right: 0; left: 0;
    height: 4px;
    background: var(--tile-color);
}

.tile:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.12);
    border-color: var(--tile-color);
}

.tile-icon {
    width: 64px; height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 1.6rem;
    color: #fff;
    background: var(--tile-color);
}

.tile-title { font-size: 1.15rem; font-weight: 700; color: #1e293b; margin-bottom: 2px; }
.tile-subtitle { font-size: 0.8rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; }

/* --- Error Page --- */
.error-page {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}

.error-page h1 { font-size: 5rem; color: #dc2626; margin-bottom: 8px; }
.error-page p { font-size: 1.2rem; color: #64748b; margin-bottom: 24px; }

.btn-back {
    background: #2563eb; color: #fff;
    padding: 12px 32px; border-radius: 10px;
    font-weight: 600; font-family: inherit; font-size: 1rem;
    transition: all 0.2s; display: inline-block;
}

.btn-back:hover { background: #1d4ed8; }

/* --- Responsive --- */
@media (max-width: 768px) {
    .navbar { padding: 0 16px; }

    .page-container { padding: 16px; }

    .page-header { flex-direction: column; }

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

    .filters-row { flex-direction: column; }
    .filters-row .form-group { width: 100%; }

    .tiles-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 12px 16px 32px;
    }

    .tile { padding: 20px 16px; }
    .tile-icon { width: 52px; height: 52px; font-size: 1.3rem; margin-bottom: 12px; }
    .tile-title { font-size: 1rem; }

    .dashboard-header { padding: 20px 16px 8px; }
    .dashboard-header h2 { font-size: 1.3rem; }

    .table th, .table td { padding: 10px 12px; font-size: 0.85rem; }
}

@media (max-width: 480px) {
    .login-card { padding: 28px 20px; }
    .navbar-user span { display: none; }
}
