@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&family=Tajawal:wght@300;400;500;700&display=swap');

:root {
    --primary: #0a2540;
    --primary-light: #0f4c75;
    --primary-dark: #061b2e;
    --accent: #1b98e0;
    --accent-light: #40b4ff;
    --accent-glow: rgba(27, 152, 224, 0.15);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f0f4f8;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 15px rgba(10,37,64,0.08);
    --shadow-lg: 0 10px 40px rgba(10,37,64,0.12);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

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

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

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 3px; }

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 40%, var(--primary-light) 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(27,152,224,0.1) 0%, transparent 70%);
    top: -200px; right: -200px;
    border-radius: 50%;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(27,152,224,0.08) 0%, transparent 70%);
    bottom: -100px; left: -100px;
    border-radius: 50%;
}

.login-box {
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-xl);
    padding: 50px 40px;
    width: 420px;
    max-width: 95%;
    position: relative;
    z-index: 1;
    animation: fadeUp 0.6s ease;
}

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

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

.login-box .logo h1 {
    color: #fff;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.login-box .logo h1 span {
    color: var(--accent);
}

.login-box .logo p {
    color: rgba(255,255,255,0.5);
    font-size: 0.85rem;
    margin-top: 5px;
}

.login-box .form-group {
    margin-bottom: 20px;
}

.login-box label {
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
    font-weight: 500;
    display: block;
    margin-bottom: 8px;
}

.login-box input {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius);
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.3s;
    outline: none;
}

.login-box input::placeholder { color: rgba(255,255,255,0.3); }
.login-box input:focus {
    border-color: var(--accent);
    background: rgba(27,152,224,0.08);
    box-shadow: 0 0 0 3px rgba(27,152,224,0.15);
}

.login-box .btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.login-box .btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(27,152,224,0.35);
}

.login-box .error-msg {
    background: rgba(239,68,68,0.15);
    border: 1px solid rgba(239,68,68,0.3);
    color: #fca5a5;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 20px;
    text-align: center;
}

/* ===== SIDEBAR LAYOUT ===== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 270px;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
    transition: all 0.3s;
    box-shadow: -5px 0 25px rgba(0,0,0,0.1);
}

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

.sidebar-header h2 {
    color: #fff;
    font-size: 1.4rem;
    font-weight: 800;
}

.sidebar-header h2 span { color: var(--accent); }

.sidebar-header .user-info {
    color: rgba(255,255,255,0.5);
    font-size: 0.78rem;
    margin-top: 5px;
}

.sidebar-nav {
    padding: 15px 12px;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    color: rgba(255,255,255,0.3);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 15px 5px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 15px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.nav-link:hover {
    background: rgba(255,255,255,0.07);
    color: #fff;
}

.nav-link.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    box-shadow: 0 4px 15px rgba(27,152,224,0.3);
}

.nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 15px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    position: absolute;
    bottom: 0;
    width: 100%;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-right: 270px;
    padding: 30px;
    min-height: 100vh;
}

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

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
}

.page-header .breadcrumb {
    color: var(--text-light);
    font-size: 0.85rem;
}

/* ===== STAT CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    border-radius: 0 4px 4px 0;
}

.stat-card.blue::before { background: var(--accent); }
.stat-card.green::before { background: var(--success); }
.stat-card.orange::before { background: var(--warning); }
.stat-card.red::before { background: var(--danger); }

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

.stat-card.blue .stat-icon { background: var(--accent-glow); color: var(--accent); }
.stat-card.green .stat-icon { background: rgba(16,185,129,0.12); color: var(--success); }
.stat-card.orange .stat-icon { background: rgba(245,158,11,0.12); color: var(--warning); }
.stat-card.red .stat-icon { background: rgba(239,68,68,0.12); color: var(--danger); }

.stat-card .stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 5px;
}

.stat-card .stat-label {
    color: var(--text-light);
    font-size: 0.82rem;
    font-weight: 500;
}

/* ===== CARDS & TABLES ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 25px;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
}

.card-body {
    padding: 24px;
}

.table-responsive {
    overflow-x: auto;
}

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

table th {
    background: var(--bg);
    padding: 12px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    text-align: right;
    white-space: nowrap;
}

table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}

table tr:last-child td { border-bottom: none; }
table tr:hover td { background: rgba(27,152,224,0.03); }

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

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
}
.btn-primary:hover { box-shadow: 0 5px 20px rgba(27,152,224,0.35); transform: translateY(-1px); }

.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-sm { padding: 7px 14px; font-size: 0.8rem; border-radius: 8px; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: #fff;
    transition: all 0.2s;
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 35px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* ===== PROGRESS BAR ===== */
.progress-bar {
    height: 10px;
    background: var(--bg);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.progress-bar .fill {
    height: 100%;
    border-radius: 5px;
    background: linear-gradient(90deg, var(--accent), var(--success));
    transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
}

.progress-bar .fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 6px;
}

.progress-label .percent {
    font-weight: 700;
    color: var(--accent);
}

/* ===== FLOOR MAP ===== */
.floor-map-container {
    background: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
    border-radius: var(--radius-lg);
    padding: 30px;
    border: 2px dashed var(--border);
    position: relative;
    min-height: 400px;
}

.room-box {
    position: absolute;
    border-radius: 12px;
    border: 2px solid var(--border);
    background: #fff;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    text-align: center;
    box-shadow: var(--shadow);
}

.room-box:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
    z-index: 10;
}

.room-box .room-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.room-box .room-progress {
    font-size: 0.7rem;
    font-weight: 600;
}

.room-box.progress-0 { border-color: #e2e8f0; background: #f8fafc; }
.room-box.progress-25 { border-color: #fbbf24; background: #fffbeb; }
.room-box.progress-50 { border-color: #fb923c; background: #fff7ed; }
.room-box.progress-75 { border-color: #38bdf8; background: #f0f9ff; }
.room-box.progress-100 { border-color: #34d399; background: #ecfdf5; }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10,37,64,0.5);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show { display: flex; }

.modal {
    background: #fff;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

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

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: var(--bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    transition: all 0.2s;
}

.modal-close:hover { background: var(--danger); color: #fff; }

.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-start;
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: rgba(16,185,129,0.12); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.12); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.12); color: var(--danger); }
.badge-info { background: var(--accent-glow); color: var(--accent); }

/* ===== ALERTS ===== */
.alert {
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 0.88rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: rgba(16,185,129,0.1); color: #065f46; border: 1px solid rgba(16,185,129,0.2); }
.alert-danger { background: rgba(239,68,68,0.1); color: #991b1b; border: 1px solid rgba(239,68,68,0.2); }
.alert-info { background: var(--accent-glow); color: var(--primary); border: 1px solid rgba(27,152,224,0.2); }

/* ===== PROJECT CARDS ===== */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.project-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.3s;
    box-shadow: var(--shadow);
}

.project-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

.project-card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 20px;
    color: #fff;
}

.project-card-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.project-card-header .owner {
    font-size: 0.82rem;
    opacity: 0.7;
}

.project-card-body {
    padding: 20px;
}

.project-card-body .info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.project-card-body .info-row:last-child { border-bottom: none; }

.project-card-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state svg { margin-bottom: 20px; opacity: 0.3; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 0.88rem; margin-bottom: 20px; }

/* ===== RESPONSIVE ===== */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 200;
    width: 45px;
    height: 45px;
    border-radius: 12px;
    background: var(--primary);
    border: none;
    color: #fff;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .mobile-toggle { display: flex; }
    .sidebar {
        transform: translateX(100%);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content {
        margin-right: 0;
        padding: 20px 15px;
        padding-top: 70px;
    }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .projects-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.gap-10 { gap: 10px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.w-100 { width: 100%; }
.d-none { display: none; }
