/* ═══════════════════════════════════════════
   Property Manager — Stylesheet
   ═══════════════════════════════════════════ */

:root {
    --bg: #f5f6fa;
    --white: #ffffff;
    --text: #2d3436;
    --text-muted: #636e72;
    --border: #dfe6e9;
    --primary: #0984e3;
    --primary-hover: #0770c2;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #d63031;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-sm: 4px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── TOP BAR ──────────────────────────────── */

.top-bar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.back-link {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.user-name {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ─── CONTAINER ────────────────────────────── */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

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

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* ─── BUTTONS ──────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    text-decoration: none;
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--text-muted);
    text-decoration: none;
}

.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
    padding: 0.3rem 0.6rem;
}

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

.btn-small {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

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

/* ─── SUMMARY ROW ──────────────────────────── */

.summary-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.summary-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.summary-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ─── FILTER BAR ───────────────────────────── */

.filter-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--white);
    min-width: 160px;
}

.filter-bar input {
    flex: 1;
    min-width: 200px;
}

/* ─── PROPERTY GRID ────────────────────────── */

.property-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.property-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s, transform 0.2s;
    text-decoration: none;
    color: var(--text);
    display: block;
    border: 1px solid transparent;
}

.property-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
    border-color: var(--primary);
}

.property-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.property-type {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.property-address {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.property-city {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
}

.property-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding-top: 0.8rem;
    border-top: 1px solid var(--border);
}

.property-rent {
    font-weight: 600;
    color: var(--success);
}

.property-docs {
    font-size: 0.8rem;
}

/* ─── STATUS BADGES ────────────────────────── */

.status-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-vacant { background: #dfe6e9; color: #636e72; }
.status-rented { background: #d4f5e9; color: #00b894; }
.status-renovation { background: #ffeaa7; color: #b8860b; }
.status-for_sale { background: #dfe6fd; color: #0984e3; }
.status-sold { background: #fab1a0; color: #d63031; }

/* ─── TABS ─────────────────────────────────── */

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    font-size: 0.95rem;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}

.tab:hover { color: var(--text); }

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.tab-count {
    background: var(--bg);
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: 0.3rem;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── DETAIL GRID ──────────────────────────── */

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.detail-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.detail-card-full {
    grid-column: 1 / -1;
}

/* ─── SHARING ──────────────────────────────── */

.sharing-list {
    margin-bottom: 0.75rem;
}

.sharing-user {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.sharing-user:last-child { border-bottom: none; }

.sharing-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.sharing-form select {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.detail-card h4 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.detail-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.4rem 1rem;
}

.detail-list dt {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.detail-list dd {
    font-size: 0.9rem;
    font-weight: 500;
}

/* ─── SECTION HEADER ───────────────────────── */

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* ─── TENANT CARDS ─────────────────────────── */

.tenant-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    border-left: 3px solid var(--success);
}

.tenant-past {
    border-left-color: var(--border);
    opacity: 0.8;
}

.tenant-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tenant-header h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tenant-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.tenant-contact {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.tenant-actions {
    display: flex;
    gap: 0.5rem;
}

.remark-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.remark-form textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 60px;
    margin-bottom: 0.5rem;
}

.remarks-list {
    margin-top: 1rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.remark-item {
    padding: 0.6rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.remark-item:last-child { border-bottom: none; }

.remark-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.remark-item p {
    font-size: 0.9rem;
}

/* ─── DOCUMENT TABLE ───────────────────────── */

.doc-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.doc-filter {
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--white);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.doc-filter:hover,
.doc-filter.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.doc-filters select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--white);
    margin-left: auto;
}

.doc-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.doc-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.doc-table td {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
}

.doc-table tr:last-child td { border-bottom: none; }

.doc-table tr:hover td { background: #fafbfc; }

.text-muted {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.cat-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.cat-legal { background: #e8daef; color: #6c3483; }
.cat-contract { background: #d4e6f1; color: #2471a3; }
.cat-invoice { background: #fdebd0; color: #b8860b; }
.cat-photo { background: #d5f5e3; color: #1e8449; }
.cat-other { background: #eaecee; color: #636e72; }

/* ─── TIMELINE ─────────────────────────────── */

.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-dot {
    position: absolute;
    left: -1.65rem;
    top: 0.3rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--white);
}

.dot-status_change { background: var(--warning); }
.dot-tenant { background: var(--success); }
.dot-repair { background: var(--danger); }
.dot-financial { background: #6c5ce7; }

.timeline-content {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.timeline-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.timeline-type {
    background: var(--bg);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.timeline-content p {
    font-size: 0.9rem;
}

/* ─── MODAL ────────────────────────────────── */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

/* ─── FORMS ────────────────────────────────── */

.form-group {
    margin-bottom: 1rem;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(9,132,227,0.1);
}

.form-row {
    display: grid;
    gap: 1rem;
}

.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ─── ALERTS ───────────────────────────────── */

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: #ffeef0;
    color: var(--danger);
    border: 1px solid #ffcdd2;
}

/* ─── EMPTY STATE ──────────────────────────── */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    grid-column: 1 / -1;
}

/* ─── LOGIN PAGE ───────────────────────────── */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
    text-align: center;
}

.login-card h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.login-card .form-group {
    text-align: left;
}

/* ─── RESPONSIVE ───────────────────────────── */

@media (max-width: 768px) {
    .top-bar { padding: 0 1rem; }
    .container { padding: 1rem; }

    .form-row-2,
    .form-row-3 { grid-template-columns: 1fr; }

    .property-grid { grid-template-columns: 1fr; }

    .summary-row { grid-template-columns: repeat(2, 1fr); }

    .tabs { overflow-x: auto; }

    .tab { padding: 0.6rem 1rem; font-size: 0.85rem; }

    .doc-table { font-size: 0.8rem; }
    .doc-table th, .doc-table td { padding: 0.5rem; }

    .tenant-header { flex-direction: column; }

    .detail-grid { grid-template-columns: 1fr; }

    .filter-bar { flex-direction: column; }
    .filter-bar select, .filter-bar input { min-width: unset; }
}

@media (max-width: 480px) {
    .summary-row { grid-template-columns: 1fr 1fr; }
    .top-bar-left .logo { font-size: 0.95rem; }
    .page-header { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
}
