/* ==========================================================================
   Dagar Rental - Custom Styles
   ========================================================================== */

/* ---------- Root Variables ---------- */
:root {
    --sidebar-width: 250px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #0d6efd;

    --admin-primary: #0d6efd;
    --admin-light: #e7f1ff;
    --agent-primary: #198754;
    --agent-light: #d1e7dd;
    --accountant-primary: #7c3aed;
    --accountant-light: #ede9fe;
    --realstate-primary: #f97316;
    --realstate-light: #fff7ed;
}

/* ---------- Global ---------- */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #f1f5f9;
    color: #1e293b;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
}

.footer {
    margin-top: auto;
}

/* ---------- Navbar Overrides ---------- */
.navbar-dark .navbar-brand {
    font-size: 1.25rem;
    letter-spacing: 0.5px;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    top: 56px; /* navbar height */
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    overflow-y: auto;
    z-index: 1000;
    padding-top: 0;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-header small {
    color: #94a3b8 !important;
}

.sidebar-nav {
    padding: 0.5rem 0;
}

.sidebar-section-title {
    padding: 0.75rem 1rem 0.35rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    color: #cbd5e1;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
    border-left-color: #475569;
}

.sidebar-link.active {
    background: rgba(13, 110, 253, 0.15);
    color: #60a5fa;
    border-left-color: var(--sidebar-active);
    font-weight: 600;
}

.sidebar-link i {
    width: 20px;
    text-align: center;
}

/* Main content with sidebar */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 1.5rem;
    min-height: calc(100vh - 56px);
}

.sidebar-toggle {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    z-index: 1050;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ---------- Dashboard Cards ---------- */
.dashboard-card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.dashboard-card .card-body {
    padding: 1.25rem;
}

.dashboard-card .card-icon {
    width: 56px;
    height: 56px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.dashboard-card .card-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.dashboard-card .card-label {
    font-size: 0.8rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Card color accents */
.card-accent-blue    { border-left: 4px solid var(--admin-primary); }
.card-accent-green   { border-left: 4px solid var(--agent-primary); }
.card-accent-purple  { border-left: 4px solid var(--accountant-primary); }
.card-accent-orange  { border-left: 4px solid var(--realstate-primary); }
.card-accent-red     { border-left: 4px solid #dc3545; }
.card-accent-teal    { border-left: 4px solid #0dcaf0; }

/* ---------- Tables ---------- */
.table-container {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.table-container .table {
    margin-bottom: 0;
}

.table thead th {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    font-weight: 600;
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-color: #f1f5f9;
    font-size: 0.9rem;
}

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

.table-search {
    max-width: 300px;
}

/* ---------- Status Badges ---------- */
.badge-active,
.badge-paid {
    background-color: #dcfce7;
    color: #166534;
}

.badge-pending {
    background-color: #fef9c3;
    color: #854d0e;
}

.badge-confirmed {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-overdue,
.badge-expired,
.badge-inactive {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-vacant {
    background-color: #e0f2fe;
    color: #075985;
}

.badge-occupied {
    background-color: #dcfce7;
    color: #166534;
}

/* ---------- Forms ---------- */
.form-container {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    padding: 2rem;
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: #374151;
    margin-bottom: 0.35rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.form-section-title {
    font-size: 1rem;
    font-weight: 600;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
    color: #1e293b;
}

/* ---------- Portal Color Themes ---------- */
/* Admin (blue) */
.portal-admin .sidebar-link.active {
    background: rgba(13, 110, 253, 0.15);
    color: #60a5fa;
    border-left-color: var(--admin-primary);
}
.portal-admin .page-title {
    color: var(--admin-primary);
}

/* Agent (green) */
.portal-agent .sidebar-link.active {
    background: rgba(25, 135, 84, 0.15);
    color: #34d399;
    border-left-color: var(--agent-primary);
}
.portal-agent .page-title {
    color: var(--agent-primary);
}
.portal-agent .form-control:focus,
.portal-agent .form-select:focus {
    border-color: var(--agent-primary);
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.15);
}

/* Accountant (purple) */
.portal-accountant .sidebar-link.active {
    background: rgba(124, 58, 237, 0.15);
    color: #a78bfa;
    border-left-color: var(--accountant-primary);
}
.portal-accountant .page-title {
    color: var(--accountant-primary);
}
.portal-accountant .form-control:focus,
.portal-accountant .form-select:focus {
    border-color: var(--accountant-primary);
    box-shadow: 0 0 0 0.2rem rgba(124, 58, 237, 0.15);
}

/* Real Estate (orange) */
.portal-realstate .sidebar-link.active {
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
    border-left-color: var(--realstate-primary);
}
.portal-realstate .page-title {
    color: var(--realstate-primary);
}
.portal-realstate .form-control:focus,
.portal-realstate .form-select:focus {
    border-color: var(--realstate-primary);
    box-shadow: 0 0 0 0.2rem rgba(249, 115, 22, 0.15);
}

/* Custom badge colors for roles */
.bg-purple {
    background-color: var(--accountant-primary) !important;
}
.bg-orange {
    background-color: var(--realstate-primary) !important;
}

/* ---------- Page Header ---------- */
.page-header {
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    font-size: 0.9rem;
    color: #64748b;
}

/* ---------- Action Buttons ---------- */
.btn-action {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border-radius: 0.35rem;
}

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

.login-card {
    width: 100%;
    max-width: 420px;
    border: none;
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-card .card-body {
    padding: 2.5rem;
}

.login-logo {
    font-size: 2rem;
    color: var(--admin-primary);
}

/* ---------- Home / Landing Page ---------- */
.hero-section {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    padding: 5rem 0;
}

.hero-section h1 {
    font-size: 2.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.hero-section .lead {
    color: #94a3b8;
    font-size: 1.2rem;
}

.portal-card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
    padding: 2rem 1.5rem;
}

.portal-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.portal-card .portal-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.75rem;
}

.feature-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
}

/* ---------- File Upload Preview ---------- */
.upload-preview {
    width: 100%;
    max-width: 200px;
    max-height: 200px;
    object-fit: cover;
    border-radius: 0.5rem;
    border: 2px dashed #e2e8f0;
    margin-top: 0.5rem;
    display: none;
}

.upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.upload-zone:hover {
    border-color: var(--admin-primary);
}

/* ---------- Responsive ---------- */

/* Tablet and below: hide sidebar, full-width content */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0 !important;
        padding: 1rem;
    }

    /* Fix navbar overflow */
    .navbar-brand {
        font-size: 1rem !important;
    }

    .navbar .badge {
        font-size: 0.65rem !important;
    }

    /* Page header stack on mobile */
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem;
    }

    .page-header .btn {
        width: 100%;
    }
}

/* Mobile phones */
@media (max-width: 767.98px) {
    /* Hero */
    .hero-section h1 {
        font-size: 1.75rem;
    }

    .hero-section {
        padding: 2.5rem 0;
    }

    .hero-section .lead {
        font-size: 1rem;
    }

    .hero-section .d-flex {
        flex-direction: column;
    }

    .hero-section .btn {
        width: 100%;
    }

    /* Dashboard cards */
    .dashboard-card .card-value {
        font-size: 1.35rem;
    }

    .dashboard-card .card-icon {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }

    /* Cards in summary row */
    .card .card-body h3 {
        font-size: 1.5rem;
    }

    .card .rounded-circle.p-3 {
        padding: 0.5rem !important;
    }

    .card .rounded-circle .fa-lg {
        font-size: 1rem;
    }

    /* Tables - make scrollable */
    .table-container,
    .table-responsive,
    .card-body .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table th, .table td {
        white-space: nowrap;
        font-size: 0.82rem;
        padding: 0.5rem 0.6rem;
    }

    /* Forms */
    .form-container {
        padding: 1.25rem;
    }

    .form-section-title {
        font-size: 0.9rem;
    }

    .form-label {
        font-size: 0.8rem;
    }

    .form-control, .form-select {
        font-size: 0.875rem;
    }

    /* Login card */
    .login-card {
        margin: 0.5rem;
        max-width: 100%;
    }

    .login-card .card-body {
        padding: 1.5rem;
    }

    .login-logo {
        font-size: 1.5rem;
    }

    /* Portal cards */
    .portal-card {
        padding: 1.25rem 1rem;
    }

    .portal-card .portal-icon {
        width: 56px;
        height: 56px;
        font-size: 1.25rem;
    }

    /* Agent dashboard alerts */
    .card-header h5 {
        font-size: 0.95rem;
    }

    .card-header small {
        font-size: 0.75rem;
    }

    /* Utility checkboxes in contract form */
    .form-check.p-2 {
        padding: 0.4rem !important;
    }

    .form-check-label {
        font-size: 0.82rem;
    }

    /* Button sizes */
    .btn-lg {
        font-size: 0.95rem;
        padding: 0.5rem 1rem;
    }

    .btn-action {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }

    /* Footer */
    .footer .row {
        text-align: center !important;
    }

    .footer .text-md-end {
        text-align: center !important;
    }

    /* Badges */
    .badge {
        font-size: 0.7rem;
    }

    .badge.fs-6 {
        font-size: 0.75rem !important;
    }

    /* Nav pills/tabs */
    .nav-tabs .nav-link,
    .nav-pills .nav-link {
        font-size: 0.82rem;
        padding: 0.4rem 0.6rem;
    }

    /* Sidebar toggle - better position on mobile */
    .sidebar-toggle {
        bottom: 0.75rem;
        left: 0.75rem;
        width: 42px;
        height: 42px;
    }

    /* Modal adjustments */
    .modal-dialog {
        margin: 0.5rem;
    }

    /* Register page */
    .register-card {
        margin: 0.5rem;
        max-width: 100%;
    }

    /* Welcome header on agent dashboard */
    .main-content > .container-fluid > .d-flex {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem;
    }
}

/* Small phones */
@media (max-width: 575.98px) {
    .page-title {
        font-size: 1.15rem;
    }

    .page-subtitle {
        font-size: 0.8rem;
    }

    .main-content {
        padding: 0.75rem;
    }

    /* Stack action buttons */
    td .btn-action {
        margin-bottom: 2px;
    }

    td form.d-inline {
        display: block !important;
    }

    /* Cards need less padding */
    .card-body {
        padding: 0.75rem;
    }

    .card-header {
        padding: 0.6rem 0.75rem;
    }

    /* Navbar user info - hide text on very small */
    .navbar .nav-item .text-light {
        font-size: 0.8rem;
    }

    /* Tables - allow wrapping on critical columns */
    .table td:first-child,
    .table td:nth-child(2) {
        white-space: normal;
        min-width: 100px;
    }

    /* Input groups */
    .input-group-text {
        padding: 0.3rem 0.5rem;
        font-size: 0.8rem;
    }

    /* Filter bars */
    .form-select, .form-control {
        font-size: 0.82rem;
    }
}

/* Print styles */
@media print {
    .sidebar, .navbar, .sidebar-toggle, .btn, footer, .page-header .btn {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .table th, .table td {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .badge {
        border: 1px solid #333;
    }
}
