/* EcoTech Security System - Main Stylesheet */
:root {
    --primary: #0066cc;
    --primary-dark: #004a99;
    --primary-light: #3389e0;
    --secondary: #00aaff;
    --accent: #00ccff;
    --white: #ffffff;
    --bg: #f0f4f8;
    --bg2: #e8eef5;
    --sidebar-bg: #001a3a;
    --sidebar-hover: #002d6b;
    --sidebar-active: #0066cc;
    --text: #1a2940;
    --text-muted: #6b8199;
    --border: #d1dde8;
    --card-shadow: 0 2px 12px rgba(0,102,204,0.1);
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
}

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

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
    position: fixed;
    top: 0; right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.sidebar-logo {
    padding: 20px 15px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-align: center;
}

.sidebar-logo .logo-img {
    max-width: 160px;
    max-height: 70px;
    object-fit: contain;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
}

.user-avatar { font-size: 2rem; color: var(--secondary); }
.user-name { display: block; color: white; font-weight: 600; font-size: 0.9rem; }
.user-role { display: block; color: var(--accent); font-size: 0.75rem; }

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

.nav-category {
    padding: 12px 20px 5px;
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.2s;
    border-right: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: white;
    border-right-color: var(--secondary);
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: white;
    border-right-color: var(--accent);
    font-weight: 700;
}

.sidebar-nav .nav-link i { width: 18px; text-align: center; font-size: 0.95rem; }
.sidebar-footer { padding: 15px; border-top: 1px solid rgba(255,255,255,0.08); }

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    transition: margin 0.3s ease;
}

/* ========== TOPBAR ========== */
.topbar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 500;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

.btn-toggle-sidebar {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--primary);
    cursor: pointer;
    padding: 5px;
}

.topbar-title h5 { font-weight: 700; color: var(--text); margin: 0; }
.topbar-right { margin-right: auto; display: flex; align-items: center; gap: 10px; }
.date-badge { background: var(--bg); padding: 5px 12px; border-radius: 20px; font-size: 0.82rem; color: var(--text-muted); }

/* ========== PAGE CONTENT ========== */
.page-content { padding: 25px; }

/* ========== CARDS ========== */
.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}

.card-header {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 15px 20px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    border-radius: 12px 12px 0 0 !important;
}

.card-header i { color: var(--primary); margin-left: 8px; }

/* ========== STAT CARDS ========== */
.stat-card {
    background: white;
    border-radius: 14px;
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,102,204,0.15); }

.stat-icon {
    width: 55px; height: 55px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.green { background: linear-gradient(135deg, #22c55e, #16a34a); color: white; }
.stat-icon.blue { background: linear-gradient(135deg, #0066cc, #0044aa); color: white; }
.stat-icon.cyan { background: linear-gradient(135deg, #00aaff, #0077cc); color: white; }
.stat-icon.orange { background: linear-gradient(135deg, #f59e0b, #d97706); color: white; }
.stat-icon.red { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; }
.stat-icon.purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); color: white; }

.stat-body { flex: 1; }
.stat-label { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 1.6rem; font-weight: 900; color: var(--text); line-height: 1.2; }
.stat-sub { font-size: 0.78rem; color: var(--text-muted); }

/* ========== BUTTONS ========== */
.btn-primary { background: var(--primary); border-color: var(--primary); font-family: 'Cairo', sans-serif; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { font-family: 'Cairo', sans-serif; font-weight: 600; }
.btn-danger { font-family: 'Cairo', sans-serif; font-weight: 600; }
.btn-warning { font-family: 'Cairo', sans-serif; font-weight: 600; }
.btn-info { font-family: 'Cairo', sans-serif; font-weight: 600; }
.btn-secondary { font-family: 'Cairo', sans-serif; font-weight: 600; }

/* ========== FORMS ========== */
.form-label { font-weight: 600; color: var(--text); font-size: 0.88rem; }
.form-control, .form-select {
    border-color: var(--border);
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
}
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,102,204,0.12); }

/* ========== TABLES ========== */
.table { font-size: 0.88rem; }
.table thead th { background: var(--bg2); color: var(--text); font-weight: 700; border-color: var(--border); }
.table-hover tbody tr:hover { background: rgba(0,102,204,0.04); }
.dataTables_wrapper .dataTables_filter input { font-family: 'Cairo', sans-serif; }
.dataTables_wrapper .dataTables_length select { font-family: 'Cairo', sans-serif; }
.table-responsive, .mobile-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive table, .mobile-scroll table { min-width: 720px; }
.btn-group.flex-wrap > .btn, .d-flex.flex-wrap > .btn { margin-bottom: .35rem; }

/* ========== BADGES ========== */
.badge { font-family: 'Cairo', sans-serif; font-weight: 600; }

/* ========== LOGIN PAGE ========== */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, #003070 50%, var(--primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: white;
    border-radius: 20px;
    padding: 50px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}

.login-logo { max-width: 200px; margin-bottom: 30px; }
.login-card h4 { font-weight: 900; color: var(--text); margin-bottom: 8px; }
.login-card p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 30px; }
.login-card .btn-primary { width: 100%; padding: 12px; font-size: 1rem; border-radius: 10px; }

/* ========== PRINT ========== */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-content { margin: 0 !important; }
    .print-header { display: flex !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

.print-header {
    display: none;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--primary);
}

.print-header img { height: 60px; }
.print-header h3 { font-weight: 900; color: var(--primary); margin: 0; }
.print-header p { color: var(--text-muted); margin: 0; font-size: 0.85rem; }

/* ========== MISC ========== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 10px;
}

.page-header h4 { font-weight: 800; color: var(--text); margin: 0; }
.page-header h4 i { color: var(--primary); margin-left: 10px; }

.section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(100%); width: 86vw; max-width: 320px; box-shadow: -10px 0 30px rgba(0,0,0,.18); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-right: 0; }
    .page-content { padding: 14px; }
    .topbar { padding: 10px 12px; height: auto; min-height: var(--topbar-height); }
    .card { border-radius: 10px; }
    .card-header { padding: 12px 14px; }
    .card-body { padding: 12px; }
    .stat-card { padding: 14px; gap: 12px; }
    .stat-value { font-size: 1.2rem; }
    .page-header { margin-bottom: 16px; }
    .page-header .btn, .page-header .btn-group { width: 100%; }
    .table-responsive table, .mobile-scroll table, .table { font-size: .82rem; }
    .table-responsive table, .mobile-scroll table { min-width: 680px; }
    .btn { padding: .5rem .75rem; }
    .modal-dialog:not(.modal-fullscreen) { margin: .35rem auto; }
    .modal-content { border-radius: 14px; }
    .row.g-3 > [class*='col-'], .row.g-2 > [class*='col-'] { margin-bottom: .15rem; }
    .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_paginate { text-align: center !important; float: none !important; }
}
@media (max-width: 576px) {
    .topbar-right { width: 100%; justify-content: space-between; }
    .date-badge { display:none; }
    .page-header h4 { font-size: 1rem; }
    .modal-dialog { max-width: calc(100vw - .5rem); }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-content { animation: fadeIn 0.3s ease; }

/* Work timer */
#workTimer { font-size: 0.85rem; padding: 6px 12px; border-radius: 20px; }

/* Invoice styles */
.invoice-product-row { background: var(--bg2); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.serial-fields { background: #f8fafc; border: 1px dashed var(--border); border-radius: 8px; padding: 12px; margin-top: 8px; }

/* Chart containers */
.chart-container { position: relative; height: 280px; }
