/* 
   =================================================
   Al-Raem Real Estate Development - Premium UI
   =================================================
*/

/* --- Variables --- */
:root {
    --primary: #0f172a;
    /* Navy Dark */
    --primary-light: #1e293b;
    --accent: #d4af37;
    /* Gold */
    --accent-hover: #b8972e;

    --bg-page: #f4f7fe;
    /* Elegant Light Gray/Blue */
    --bg-surface: #ffffff;

    --text-dark: #1e293b;
    --text-p: #475569;
    --text-muted: #94a3b8;

    --border: #e2e8f0;
    --border-focus: #cbd5e1;

    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.1), 0 2px 4px -1px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -2px rgba(15, 23, 42, 0.05);

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
}

body {
    background-color: var(--bg-page);
    color: var(--text-p);
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-dark);
    font-weight: 700;
    line-height: 1.3;
}

p {
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    outline: none;
    border: none;
    cursor: pointer;
    background: none;
    font-family: inherit;
}

/* Utilities */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.gold-text {
    color: var(--accent);
}

.danger-text {
    color: var(--danger);
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.mt-5 {
    margin-top: 2rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.px-4 {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.ms-2 {
    margin-left: 0.5rem;
}

.me-2 {
    margin-right: 0.5rem;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-dark);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-sm {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-p);
    transition: var(--transition);
}

.btn-icon:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.btn-icon.danger {
    color: var(--danger);
}

.btn-icon.danger:hover {
    background: #fef2f2;
    color: var(--danger);
}

.btn-icon.primary {
    color: var(--primary);
}

.btn-icon.primary:hover {
    background: #e0e7ff;
}

/* --- Forms & Inputs --- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    background: #f8fafc;
    border: 1px solid var(--border-focus);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    color: var(--text-dark);
}

.form-control:focus {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
    outline: none;
}

.input-icon {
    position: relative;
}

.input-icon i {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-icon .form-control,
.input-icon input {
    padding-right: 2.8rem;
    width: 100%;
    border: 1px solid var(--border-focus);
    border-radius: var(--radius-sm);
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    padding-left: 1rem;
    font-size: 0.95rem;
}

/* Fallback */
.input-icon input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
    outline: none;
}

.error-text {
    color: var(--danger);
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.5rem;
    text-align: center;
}

/* Custom Checkbox */
.checkbox-group {
    margin-top: 1rem;
}

.custom-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600 !important;
    color: var(--text-dark) !important;
    user-select: none;
}

.custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    height: 20px;
    width: 20px;
    background-color: #f1f5f9;
    border: 1px solid var(--border-focus);
    border-radius: 4px;
    margin-left: 10px;
    position: relative;
    transition: var(--transition);
}

.custom-checkbox:hover input~.checkmark {
    background-color: #e2e8f0;
}

.custom-checkbox input:checked~.checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.custom-checkbox input:checked~.checkmark:after {
    display: block;
}

/* --- Layout --- */
#app-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-container {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* --- Navbar Core --- */
.navbar {
    background: var(--bg-surface);
    padding: 0 2rem;
    height: 75px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.nav-container {
    width: 100%;
    max-width: 1400px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    cursor: pointer;
}

.nav-brand i {
    font-size: 1.6rem;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-greeting {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

/* --- Badges --- */
.badge-role {
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.b-manager {
    background: #e0e7ff;
    color: #4f46e5;
}

.b-engineer {
    background: #dcfce7;
    color: #16a34a;
}

.b-accountant {
    background: #fef9c3;
    color: #ca8a04;
}

.b-supervisor {
    background: #ffe4e6;
    color: #e11d48;
}

.b-worker {
    background: #f1f5f9;
    color: #64748b;
}

/* Active inactive badge */
.b-active {
    background: #dcfce7;
    color: #16a34a;
}

.b-inactive {
    background: #f3f4f6;
    color: #9ca3af;
}

/* --- Views Transitions --- */
.view-section {
    animation: fadeUp 0.4s ease forwards;
    display: none;
}

.view-section.active {
    display: block;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Common Headers --- */
.section-header {
    margin-bottom: 2rem;
}

.section-header p {
    font-size: 1.05rem;
    margin-top: 0.3rem;
}

.section-header.with-back {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.section-header.with-back .btn-icon {
    background: var(--bg-surface);
    box-shadow: var(--shadow-sm);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 1.2rem;
}

.section-subtitle {
    color: var(--primary);
    font-size: 1.3rem;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
    padding-bottom: 0.4rem;
}

/* --- Dashboard --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-box {
    background: var(--bg-surface);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: var(--transition);
    border: 1px solid var(--border);
}

.stat-box:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #fef9c3;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-info p {
    margin-bottom: 0.2rem;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.stat-info h3 {
    font-size: 1.8rem;
    color: var(--primary);
}

.nav-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.nav-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.nav-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
}

.nav-card:hover .card-icon {
    background: var(--primary);
    color: var(--accent);
    transform: scale(1.05);
}

.nav-card:hover .card-arrow {
    right: 2rem;
    opacity: 1;
}

.card-icon {
    width: 70px;
    height: 70px;
    border-radius: var(--radius-md);
    background: #f8fafc;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.card-content h3 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    transition: color 0.3s;
}

.card-content p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.card-arrow {
    position: absolute;
    left: 2rem;
    top: 2rem;
    font-size: 1.5rem;
    color: var(--accent);
    opacity: 0;
    transition: var(--transition);
    transform: rotate(180deg);
    /* RTL adjustment if needed, but awesome font handles arrow-left contextually well */
}

/* --- Internal Sections Tools --- */
.toolbar-card {
    background: var(--bg-surface);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.search-wrapper {
    position: relative;
    width: 100%;
    max-width: 350px;
}

.search-wrapper i {
    position: absolute;
    right: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-wrapper input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 3rem;
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: 30px;
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}

.search-wrapper input:focus {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

/* --- Premium Tables (Desktop) --- */
.table-container {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1rem;
    overflow: hidden;
}

.modern-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: right;
}

.modern-table th {
    background: #f8fafc;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 800;
    padding: 1rem;
    border-bottom: 2px solid #e2e8f0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modern-table td {
    padding: 1.2rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-dark);
    font-weight: 600;
    vertical-align: middle;
}

.modern-table tbody tr {
    transition: var(--transition);
}

.modern-table tbody tr:hover {
    background: #f8fafc;
}

.modern-table tbody tr:last-child td {
    border-bottom: none;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

/* --- Modals (Sleek) --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    /* Bottom on mobile */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-dialog {
    width: 100%;
    max-width: 700px;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: var(--bg-surface);
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal.show .modal-dialog {
    transform: translateY(0);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.3rem;
    color: var(--primary);
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

.modal-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Login */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 1rem;
}

.login-card {
    background: var(--bg-surface);
    width: 100%;
    max-width: 420px;
    padding: 3rem 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border-top: 5px solid var(--accent);
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-header .logo i {
    font-size: 3.5rem;
    margin-bottom: 1rem;
}

/* Toasts */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary);
    color: #fff;
    padding: 1rem 1.5rem;
    border-radius: 30px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    z-index: 2000;
    opacity: 0;
    transition: all 0.4s ease;
    font-weight: 600;
}

.toast.toast-show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* --- Mobile Responsiveness --- */
@media (min-width: 768px) {
    .modal {
        align-items: center;
    }

    .modal-dialog {
        border-radius: var(--radius-lg);
        transform: translateY(-30px);
    }

    .modal.show .modal-dialog {
        transform: translateY(0);
    }

    .form-col-2 {
        grid-column: span 2;
    }

    .form-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

@media (max-width: 767px) {
    .main-container {
        padding: 1rem;
    }

    .navbar {
        padding: 0 1rem;
        height: 65px;
    }

    .nav-brand span {
        display: none;
    }

    /* Hide text, keep icon */
    .hide-mobile {
        display: none;
    }

    .user-greeting {
        font-size: 0.9rem;
    }

    .toolbar-card {
        flex-direction: column;
        align-items: stretch;
    }

    .search-wrapper {
        max-width: 100%;
    }

    .section-header.with-back h2 {
        font-size: 1.4rem;
    }

    /* Elegant Mobile Table -> Card Conversion */
    .table-container {
        padding: 0;
        background: transparent;
        box-shadow: none;
        overflow: visible;
    }

    .modern-table thead {
        display: none;
    }

    .modern-table tbody tr {
        display: block;
        background: var(--bg-surface);
        margin-bottom: 1rem;
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        border: 1px solid var(--border);
        padding: 1.25rem;
    }

    .modern-table tbody tr:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

    .modern-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 0;
        border-bottom: 1px dashed var(--border);
    }

    .modern-table td:last-child {
        border-bottom: none;
        display: flex;
        justify-content: center;
        gap: 1rem;
        padding-top: 1rem;
        margin-top: 0.5rem;
        border-top: 1px solid var(--border);
    }

    .modern-table td::before {
        content: attr(data-label);
        font-size: 0.85rem;
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
    }

    .modal-body {
        padding: 1.5rem 1rem;
    }
}