/* ==================================================
   Tailor Shop Management System
   Professional RTL Business Stylesheet
================================================== */

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

body {
    font-family: Tahoma, Arial, sans-serif;
    background: #f1f5f9;
    color: #0f172a;
    direction: rtl;
    min-height: 100vh;
}

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

/* ==================================================
   App Layout (Sidebar + Main)
================================================== */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ==================================================
   Sidebar
================================================== */

.sidebar {
    width: 240px;
    min-height: 100vh;
    background: #0f172a;
    color: #cbd5e1;
    position: fixed;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.2);
}

.sidebar-brand {
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand i {
    font-size: 22px;
    color: #60a5fa;
}

.sidebar-brand-name {
    font-size: 15px;
    font-weight: bold;
    color: #f1f5f9;
    line-height: 1.3;
}

.sidebar-brand-sub {
    font-size: 11px;
    color: #475569;
    margin-top: 1px;
}

.sidebar-nav {
    padding: 10px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #475569;
    padding: 12px 18px 4px;
    letter-spacing: 0.08em;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: #94a3b8;
    font-size: 13.5px;
    transition: background 0.15s, color 0.15s;
    border-right: 3px solid transparent;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-right-color: #3b82f6;
    font-weight: 600;
}

.nav-item i {
    width: 18px;
    text-align: center;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    font-size: 12px;
    color: #475569;
}

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

.main-content {
    margin-right: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ==================================================
   Top Header Bar
================================================== */

.topbar {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-page-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.topbar-breadcrumb {
    font-size: 13px;
    color: #94a3b8;
}

.topbar-breadcrumb span {
    margin: 0 4px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: #1d4ed8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 13px;
    font-weight: bold;
}

.user-name {
    font-size: 13px;
    color: #374151;
    font-weight: 600;
}

.user-role-badge {
    background: #dbeafe;
    color: #1e40af;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.user-role-badge.sales {
    background: #d1fae5;
    color: #065f46;
}

/* ==================================================
   Container
================================================== */

.container {
    padding: 24px;
    max-width: 100%;
}

.page-header {
    margin-bottom: 20px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.page-subtitle {
    font-size: 13px;
    color: #64748b;
    margin-top: 4px;
}

.en {
    direction: ltr;
    unicode-bidi: embed;
    color: #94a3b8;
    font-size: 11px;
}

/* ==================================================
   Cards
================================================== */

.card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.card-title i {
    color: #1d4ed8;
    font-size: 14px;
}

/* ==================================================
   Dashboard Stat Cards
================================================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 18px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    border-right: 4px solid #e2e8f0;
    position: relative;
    overflow: hidden;
}

.stat-card.blue   { border-right-color: #1d4ed8; }
.stat-card.green  { border-right-color: #16a34a; }
.stat-card.orange { border-right-color: #d97706; }
.stat-card.red    { border-right-color: #dc2626; }
.stat-card.purple { border-right-color: #7c3aed; }
.stat-card.teal   { border-right-color: #0891b2; }
.stat-card.amber  { border-right-color: #f59e0b; }
.stat-card.slate  { border-right-color: #64748b; }

.stat-bg-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 32px;
    opacity: 0.08;
}

.stat-card.blue   .stat-bg-icon { color: #1d4ed8; }
.stat-card.green  .stat-bg-icon { color: #16a34a; }
.stat-card.orange .stat-bg-icon { color: #d97706; }
.stat-card.red    .stat-bg-icon { color: #dc2626; }
.stat-card.purple .stat-bg-icon { color: #7c3aed; }
.stat-card.teal   .stat-bg-icon { color: #0891b2; }
.stat-card.amber  .stat-bg-icon { color: #f59e0b; }
.stat-card.slate  .stat-bg-icon { color: #64748b; }

.stat-label {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1;
}

.stat-sub {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 6px;
}

/* ==================================================
   Quick Actions
================================================== */

.quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: white;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 18px;
    min-width: 110px;
    color: #374151;
    font-size: 12.5px;
    font-family: Tahoma, Arial, sans-serif;
    font-weight: 600;
    transition: border-color 0.15s, box-shadow 0.15s, color 0.15s;
    cursor: pointer;
    text-align: center;
}

.quick-action-btn:hover {
    border-color: #1d4ed8;
    box-shadow: 0 2px 8px rgba(29, 78, 216, 0.1);
    color: #1d4ed8;
}

.quick-action-btn i {
    font-size: 20px;
    color: #1d4ed8;
}

/* ==================================================
   Buttons
================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #1d4ed8;
    color: #ffffff;
    border: none;
    padding: 9px 16px;
    border-radius: 7px;
    font-size: 13px;
    font-family: Tahoma, Arial, sans-serif;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.15s, transform 0.1s;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.98); }

.btn-primary   { background: #1d4ed8; color: white; }
.btn-success   { background: #16a34a; color: white; }
.btn-warning   { background: #d97706; color: white; }
.btn-danger    { background: #dc2626; color: white; }
.btn-secondary { background: #64748b; color: white; }
.btn-info      { background: #0891b2; color: white; }

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 5px;
    gap: 4px;
}

/* ==================================================
   Forms
================================================== */

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

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

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

.form-group {
    min-width: 0;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

input,
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 7px;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 13.5px;
    color: #111827;
    background: #ffffff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #1d4ed8;
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

input[readonly] {
    background: #f8fafc;
    color: #64748b;
    cursor: default;
}

textarea {
    min-height: 90px;
    resize: vertical;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.form-hint {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 4px;
}

/* ==================================================
   Filter / Search Bar
================================================== */

.filter-bar {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
}

.filter-bar-title {
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto auto;
    gap: 10px;
    align-items: end;
}

/* Legacy alias */
.search-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
}

/* ==================================================
   Tables
================================================== */

.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 13px;
}

thead tr {
    background: #f8fafc;
}

th {
    padding: 11px 12px;
    text-align: right;
    font-size: 11.5px;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    background: #f8fafc;
}

td {
    padding: 10px 12px;
    text-align: right;
    color: #111827;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: #f8fafc;
}

td.actions {
    white-space: nowrap;
}

td.actions a,
td.actions button {
    margin: 2px;
}

.table-empty {
    text-align: center !important;
    color: #94a3b8;
    padding: 36px 16px !important;
    font-size: 13px;
}

/* ==================================================
   Status Badges
================================================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-completed {
    background: #d1fae5;
    color: #065f46;
}

.status-submitted {
    background: #dbeafe;
    color: #1e40af;
}

.status-cancelled {
    background: #fee2e2;
    color: #991b1b;
}

/* ==================================================
   Alerts
================================================== */

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13.5px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-right: 4px solid transparent;
    font-weight: 500;
}

.alert i {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border-right-color: #16a34a;
}

.alert-error,
.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border-right-color: #dc2626;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border-right-color: #1d4ed8;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-right-color: #d97706;
}

/* ==================================================
   Logo
================================================== */

.shop-logo,
.logo-preview {
    width: 64px;
    height: 64px;
    border: 2px solid #e2e8f0;
    border-radius: 50%;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: white;
}

.logo-preview {
    width: 90px;
    height: 90px;
}

.empty-logo {
    width: 64px;
    height: 64px;
    border: 2px dashed #cbd5e1;
    border-radius: 50%;
    background: #f8fafc;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 22px;
}

/* ==================================================
   Order Form Specific
================================================== */

.order-form {
    font-size: 14px;
    direction: rtl;
}

.order-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.order-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.order-header-info {
    flex: 1;
    text-align: right;
}

.order-shop-name {
    font-size: 20px;
    font-weight: bold;
    color: #1d4ed8;
    margin: 0;
}

.order-shop-en {
    font-size: 13px;
    color: #64748b;
    margin: 4px 0 0;
}

.order-shop-address {
    font-size: 12px;
    color: #94a3b8;
    margin: 3px 0 0;
}

.order-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #1d4ed8;
    margin: 0 0 10px;
    padding-bottom: 6px;
    border-bottom: 1.5px solid #eff6ff;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.order-grid {
    display: grid;
    gap: 8px;
}

.order-grid-2 { grid-template-columns: repeat(2, 1fr); }
.order-grid-3 { grid-template-columns: repeat(3, 1fr); }
.order-grid-4 { grid-template-columns: repeat(4, 1fr); }
.order-grid-5 { grid-template-columns: repeat(5, 1fr); }

.ofield {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ofield-label {
    font-size: 11.5px;
    font-weight: 600;
    color: #1d4ed8;
    padding: 4px 8px;
    background: #eff6ff;
    border-radius: 6px 6px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ofield-input {
    background: #fafafa;
    min-height: 32px;
    border-radius: 0 0 6px 6px;
    border: 1.5px solid #e2e8f0;
    border-top: none;
    display: flex;
    align-items: center;
}

.ofield-input input,
.ofield-input select,
.ofield-input textarea {
    width: 100%;
    height: 32px;
    border: none;
    background: transparent;
    padding: 5px 8px;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 13px;
    outline: none;
    color: #111827;
}

.ofield-input textarea {
    min-height: 70px;
    resize: vertical;
    height: auto;
}

.ofield-value {
    background: #fafafa;
    min-height: 32px;
    border-radius: 0 0 6px 6px;
    border: 1.5px solid #e2e8f0;
    border-top: none;
    padding: 7px 8px;
    font-weight: 600;
    color: #111827;
    overflow-wrap: anywhere;
}

/* ==================================================
   Info Grid (for profile/detail views)
================================================== */

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.info-item {
    min-width: 0;
}

.info-item .info-label {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.info-item .info-value {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

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

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.section-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title i { color: #1d4ed8; }

/* ==================================================
   Sidebar User Info & Logout
================================================== */

.sidebar-user-info {
    padding: 14px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-role-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 999px;
}

.sidebar-role-badge.admin {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}

.sidebar-role-badge.sales {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: #64748b;
    margin-top: 10px;
    padding: 6px 0;
    transition: color 0.15s;
    cursor: pointer;
}

.sidebar-logout:hover {
    color: #f87171;
}

/* ==================================================
   Login Page
================================================== */

body.login-page {
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    flex-direction: column;
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.login-logo {
    text-align: center;
    margin-bottom: 20px;
}

.login-logo i {
    font-size: 44px;
    color: #1d4ed8;
}

.login-title {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    text-align: center;
    margin: 0 0 8px;
}

.login-subtitle {
    font-size: 13px;
    color: #64748b;
    text-align: center;
    margin: 0 0 28px;
    line-height: 1.6;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: #334155;
}

/* ==================================================
   Print Helpers
================================================== */

.print-toolbar {
    text-align: center;
    margin: 10px 0;
}

@media print {
    body { background: white; }
    .print-toolbar, .sidebar, .topbar, .no-print { display: none !important; }
    .main-content { margin-right: 0 !important; }
    .card, .order-card, .stat-card { box-shadow: none !important; border: 1px solid #e2e8f0 !important; }
    .app-layout { display: block; }
}

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

@media (max-width: 1024px) {
    .sidebar { display: none; }
    .main-content { margin-right: 0; }
}

@media (max-width: 768px) {
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
    .search-grid { grid-template-columns: 1fr; }
    .form-grid,
    .form-grid-3,
    .form-grid-4 { grid-template-columns: 1fr; }
    .order-grid-2,
    .order-grid-3,
    .order-grid-4,
    .order-grid-5 { grid-template-columns: 1fr; }
    .container { padding: 16px; }
    .info-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
    .container { padding: 12px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .order-header { flex-direction: column; text-align: center; }
    .order-header-info { text-align: center; }
    .info-grid { grid-template-columns: 1fr; }
}
