/* RentSuite Styles - Modern, Clean, Responsive */

:root {
    --primary: #4A90E2;
    --primary-dark: #357ABD;
    --secondary: #50C878;
    --danger: #E74C3C;
    --warning: #F39C12;
    --dark: #2C3E50;
    --light: #ECF0F1;
    --gray: #95A5A6;
    --white: #FFFFFF;
    --border: #DDD;
    --shadow: rgba(0, 0, 0, 0.1);
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--dark);
    background: var(--light);
}

/* Login Page Styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient);
    padding: 20px;
}

.login-box {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 10px 40px var(--shadow);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

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

.login-logo i {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 10px;
}

.login-logo h1 {
    font-size: 28px;
    color: var(--dark);
    margin-bottom: 5px;
}

.login-logo p {
    color: var(--gray);
    font-size: 14px;
}

/* Navigation */
.navbar {
    background: var(--white);
    box-shadow: 0 2px 4px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* min-height (not a fixed height) so the no-JS wrap fallback can grow to
       fit extra rows instead of overlapping the page. With JS enhancement the
       bar is a single row and stays 60px. */
    min-height: 60px;
}

.nav-brand {
    display: flex;
    align-items: center;
    color: var(--primary);
}

.nav-brand i {
    margin-right: 10px;
    font-size: 24px;
}

.nav-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    font-size: 20px;
    font-weight: bold;
}

.nav-version {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--gray);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--dark);
    cursor: pointer;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1 1 auto;
    min-width: 0;
}

/* Role nav links. No-JS fallback: items wrap to a new row instead of being
   clipped. When app.js enhances the bar, .is-enhanced switches this to a
   single row and overflow is moved into the "More" menu (priority-plus). */
.nav-links {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 0 1 auto;
    min-width: 0;
    margin-left: 20px;
    flex-wrap: wrap;
}

.navbar.is-enhanced .nav-links {
    flex-wrap: nowrap;
    overflow: hidden;
}

.nav-menu .nav-item {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* "More" overflow control */
.nav-more {
    position: relative;
    flex: 0 0 auto;
}

.nav-more[hidden] {
    display: none;
}

.nav-more__toggle {
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
    color: var(--dark);
}

.nav-more__toggle.has-active {
    color: var(--primary);
}

.nav-more__menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 210px;
    background: var(--white);
    box-shadow: 0 4px 12px var(--shadow);
    border-radius: 6px;
    padding: 4px 0;
    display: none;
    z-index: 1001;
}

.nav-more.open .nav-more__menu {
    display: block;
}

.nav-more.open .nav-more__toggle {
    background: var(--light);
    color: var(--primary);
}

.nav-more__menu .nav-item {
    width: 100%;
    border-radius: 0;
    padding: 12px 16px;
}

.nav-more__menu .nav-item:hover {
    background: var(--light);
}

.nav-item {
    padding: 8px 16px;
    color: var(--dark);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-item:hover {
    background: var(--light);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary);
    color: var(--white);
}

.nav-user {
    position: relative;
    padding: 8px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 6px;
    transition: background 0.3s;
    /* Pin the account menu to the far right; links + "More" stay grouped left. */
    margin-left: auto;
}

.nav-user:hover {
    background: var(--light);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    box-shadow: 0 4px 12px var(--shadow);
    border-radius: 6px;
    padding-top: 4px;
    min-width: 180px;
    display: none;
    z-index: 1000;
}

/* Invisible bridge to prevent hover gap */
.nav-user::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 0;
    width: 100%;
    height: 10px;
    display: none;
}

.nav-user:hover::after {
    display: block;
}

.nav-user:hover .user-dropdown {
    display: block;
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--dark);
    text-decoration: none;
    transition: background 0.3s;
}

.user-dropdown a:hover {
    background: var(--light);
}

/* Main Content */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 20px;
}

.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: 28px;
    color: var(--dark);
    margin-bottom: 10px;
}

.page-header p {
    color: var(--gray);
}

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

.stat-card {
    background: var(--white);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--white);
}

.stat-icon.blue { background: var(--primary); }
.stat-icon.green { background: var(--secondary); }
.stat-icon.orange { background: var(--warning); }
.stat-icon.red { background: var(--danger); }

.stat-details h3 {
    font-size: 32px;
    color: var(--dark);
    margin-bottom: 5px;
}

.stat-details p {
    color: var(--gray);
    font-size: 14px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark);
}

.form-group label.required:after {
    content: ' *';
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.form-control:disabled {
    background: var(--light);
    cursor: not-allowed;
}

select.form-control {
    cursor: pointer;
}

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

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

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray);
    color: var(--white);
}

.btn-secondary:hover {
    background: #7F8C8D;
}

.btn-success {
    background: var(--secondary);
    color: var(--white);
}

.btn-success:hover {
    background: #45B369;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #C0392B;
}

.btn-warning {
    background: var(--warning);
    color: var(--white);
}

.btn-info {
    background: #17a2b8;
    color: var(--white);
}

.btn-info:hover {
    background: #138496;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    margin-bottom: 20px;
}

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

.card-header h2 {
    font-size: 20px;
    color: var(--dark);
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    background: var(--light);
    border-radius: 0 0 12px 12px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

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

.table thead {
    background: var(--light);
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    color: var(--dark);
}

.table tbody tr:hover {
    background: var(--light);
}

.table-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* v2.5 §15 — row-action buttons: moderately larger targets, keyboard focus, tooltip support.
   Scoped to .table-actions / .rs-action-btn so the global .btn-sm (filter tabs etc.) is untouched. */
.table-actions form {
    display: inline-flex;
}

.table-actions .btn-sm,
.rs-action-btn {
    min-width: 34px;
    min-height: 32px;
    padding: 7px 10px;
    font-size: 13px;
    justify-content: center;
}

.btn:focus-visible,
.rs-action-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

@media (pointer: coarse) {
    .table-actions .btn-sm,
    .rs-action-btn {
        min-width: 42px;
        min-height: 40px;
    }
}

/* Body-portaled action tooltip: position:fixed dodges the overflow-x containers
   that clip absolutely-positioned tips (e.g. the transactions table wrapper). */
#rs-action-tip {
    position: fixed;
    z-index: 10050;
    background: #1e293b;
    color: #fff;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.35;
    max-width: 260px;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

#rs-action-tip[hidden] {
    display: none;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #D5F4E6;
    color: var(--secondary);
}

.badge-warning {
    background: #FCF3CF;
    color: var(--warning);
}

.badge-danger {
    background: #FADBD8;
    color: var(--danger);
}

.badge-primary {
    background: #D6EAF8;
    color: var(--primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: var(--dark);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray);
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 3000;
}

.toast {
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow);
    padding: 16px 20px;
    margin-bottom: 10px;
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s;
}

.toast-success {
    border-left: 4px solid var(--secondary);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-info {
    border-left: 4px solid var(--primary);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Calendar */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.calendar-nav {
    display: flex;
    gap: 10px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
}

.calendar-day-header {
    background: var(--light);
    padding: 12px;
    text-align: center;
    font-weight: 600;
    color: var(--dark);
}

.calendar-day {
    background: var(--white);
    min-height: 100px;
    padding: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

.calendar-day:hover {
    background: var(--light);
}

.calendar-day.other-month {
    opacity: 0.5;
}

.calendar-day-number {
    font-weight: 600;
    margin-bottom: 8px;
}

.calendar-event {
    background: var(--primary);
    color: var(--white);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    margin-bottom: 4px;
    cursor: pointer;
}

.calendar-event.paid {
    background: var(--secondary);
}

.calendar-event.overdue {
    background: var(--danger);
}

/* Footer */
.footer {
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 20px;
    text-align: center;
    color: var(--gray);
    font-size: 14px;
    margin-top: 40px;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }
    
    .nav-menu {
        position: fixed;
        top: 60px;
        left: -100%;
        width: 80%;
        height: calc(100vh - 60px);
        background: var(--white);
        flex-direction: column;
        align-items: flex-start;
        padding: 20px;
        transition: left 0.3s;
        box-shadow: 2px 0 8px var(--shadow);
    }
    
    .nav-menu.active {
        left: 0;
    }

    /* Drawer shows the full list as a column — no overflow collapsing here. */
    .nav-links,
    .navbar.is-enhanced .nav-links {
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: flex-start;
        overflow: visible;
        width: 100%;
        margin-left: 0;
        gap: 0;
    }

    .nav-more {
        display: none !important;
    }

    .nav-item {
        width: 100%;
    }
    
    .nav-user {
        width: 100%;
        margin-left: 0;
    }

    .user-dropdown {
        position: static;
        box-shadow: none;
        margin-top: 10px;
        display: none;
    }
    
    .nav-user.active .user-dropdown {
        display: block;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .table-container {
        overflow-x: scroll;
    }
    
    .calendar-day {
        min-height: 80px;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.hidden { display: none; }
.flex { display: flex; }
.flex-between { justify-content: space-between; }
.flex-center { justify-content: center; align-items: center; }
.gap-10 { gap: 10px; }
