:root {
    --primary: #1a5276;
    --primary-light: #2e86c1;
    --primary-dark: #0e2f44;
    --accent: #3498db;
    --bg-light: #f0f4f8;
    --sidebar-width: 260px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { overflow-x: hidden; }

body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg-light);
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
}

body.sidebar-open {
    overflow: hidden;
}

/* Login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card .logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-card .logo h2 {
    color: var(--primary);
    font-weight: 700;
}

.login-card .logo p {
    color: #666;
    font-size: 14px;
}

/* Sidebar Layout */
.wrapper {
    display: flex;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--primary-dark);
    color: #fff;
    min-height: 100vh;
    position: fixed;
    transition: transform 0.3s ease, width 0.3s ease;
    z-index: 1000;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: relative;
}

.sidebar-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.sidebar-header small {
    color: rgba(255,255,255,0.6);
    font-size: 12px;
}

.sidebar-close {
    display: none;
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.7;
    line-height: 1;
}

.sidebar-close:hover {
    opacity: 1;
}

.sidebar .nav-link {
    color: rgba(255,255,255,0.7);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    font-size: 14px;
    text-decoration: none;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.sidebar .nav-link i {
    width: 20px;
    text-align: center;
}

.sidebar .nav-item .sub-menu {
    padding-left: 20px;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-backdrop.show {
    display: block;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--primary);
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
}

.sidebar-toggle:hover {
    color: var(--primary-dark);
}

.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 20px 30px;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.top-bar {
    background: #fff;
    padding: 15px 25px;
    margin: -20px -30px 20px -30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.top-bar .page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}

.top-bar .user-info {
    font-size: 14px;
    color: #666;
    white-space: nowrap;
}

/* Cards */
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border-left: 4px solid var(--primary);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    font-size: 32px;
    color: var(--primary-light);
    opacity: 0.5;
}

.stat-card .stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-dark);
}

.stat-card .stat-label {
    font-size: 14px;
    color: #888;
}

/* Tables */
.table-container {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.table-container .table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px;
    flex-wrap: wrap;
}

.table-container .table-header h5 {
    white-space: nowrap;
}

/* Forms */
.form-card {
    background: #fff;
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    max-width: 700px;
}

.form-card label {
    font-weight: 600;
    color: #444;
    font-size: 14px;
}

.form-card .form-control {
    border-radius: 6px;
    border: 1px solid #ddd;
    padding: 10px 14px;
}

.form-card .form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 0.2rem rgba(46, 134, 193, 0.15);
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* Map */
#map-container {
    height: 600px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-width: 100%;
}

#stall-map {
    height: 500px;
    border-radius: 8px;
    max-width: 100%;
    overflow: hidden;
}

/* Tenant Dashboard */
.tenant-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 20px;
}

.tenant-header h2 {
    font-weight: 700;
}

.tenant-header p {
    opacity: 0.9;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: #888;
    font-size: 13px;
}

/* Flash messages */
.alert {
    border-radius: 8px;
}

/* Landing page hero */
.hero h1 { font-weight: 700; font-size: 36px; }
.hero p { opacity: 0.9; font-size: 18px; }

/* DataTable responsive wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
}

.dataTables_wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

.dataTables_wrapper table {
    width: 100% !important;
    table-layout: auto;
}

.dataTables_wrapper table td,
.dataTables_wrapper table th {
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 767px) {
    .dataTables_wrapper table td,
    .dataTables_wrapper table th {
        white-space: normal;
        word-break: break-word;
        max-width: 120px;
    }
}

/* Responsive images */
img {
    max-width: 100%;
    height: auto;
}

/* ======= RESPONSIVE: Tablet / Mobile ======= */
@media (max-width: 991px) {
    .stat-card .stat-number {
        font-size: 24px;
    }
}

@media (max-width: 767px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-close {
        display: block;
    }

    .sidebar-toggle {
        display: inline-block;
    }

    .sidebar-backdrop.show {
        display: block;
    }

    .content {
        margin-left: 0;
        padding: 15px;
    }

    .top-bar {
        padding: 12px 15px;
        margin: -15px -15px 15px -15px;
    }

    .top-bar .page-title {
        font-size: 16px;
    }

    .top-bar .user-info {
        font-size: 12px;
    }

    .top-bar .user-info .btn-sm {
        font-size: 11px;
        padding: 3px 8px;
    }

    .hero h1 { font-size: 28px; }
    .hero p { font-size: 16px; }

    .login-card {
        width: calc(100% - 30px);
        max-width: 380px;
        padding: 25px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-card .stat-number {
        font-size: 22px;
    }

    .stat-card .stat-icon {
        font-size: 26px;
    }

    .table-container {
        padding: 12px;
    }

    .table-container .table-header h5 {
        font-size: 14px;
        white-space: normal;
    }

    .form-card {
        padding: 20px;
        max-width: 100%;
    }

    #map-container {
        height: 350px;
    }

    .stall-list {
        max-height: 300px !important;
    }

    #stall-map {
        height: 350px !important;
    }

    .tenant-header {
        padding: 20px;
    }

    .tenant-header h2 {
        font-size: 20px;
    }

    .row.g-3 > [class*="col-"] {
        margin-bottom: 0;
    }
}

@media (max-width: 575px) {
    .sidebar {
        width: 100%;
    }

    .hero h1 { font-size: 22px; }
    .hero p { font-size: 14px; }

    .content {
        padding: 10px;
    }

    .top-bar {
        padding: 10px;
        margin: -10px -10px 10px -10px;
    }

    .top-bar .page-title {
        font-size: 14px;
    }

    .stat-card .stat-number {
        font-size: 20px;
    }

    .table-container {
        padding: 10px;
        border-radius: 6px;
    }

    .table-container .table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .table-container .table-header > div {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }

    .table-container .table-header .btn {
        font-size: 12px;
        padding: 4px 10px;
    }

    #map-container {
        height: 280px;
    }

    #stall-map {
        height: 280px !important;
    }

    .stall-list {
        max-height: 200px !important;
    }

    .tenant-header {
        padding: 15px;
        border-radius: 6px;
    }

    .tenant-header h2 {
        font-size: 18px;
    }

    .form-card {
        padding: 15px;
        border-radius: 6px;
    }

    .login-card {
        padding: 20px;
        border-radius: 8px;
    }

    .modal-dialog {
        margin: 10px;
    }

    .dataTables_wrapper .dataTables_filter input {
        max-width: 150px;
    }
}
