/* style.css - Real Estate Sales App */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
}

/* ── Navbar ───────────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1e3a5f;
    color: #fff;
    padding: 0.75rem 1.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand { font-size: 1.2rem; font-weight: 700; }
.nav-links  { list-style: none; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.nav-links a {
    color: #cdd8f0;
    text-decoration: none;
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background 0.2s;
}
.nav-links a:hover, .nav-links a.active {
    background: #4f6ef7;
    color: #fff;
}
.nav-user { font-size: 0.9rem; color: #cdd8f0; }
.nav-user a { color: #ff7675; text-decoration: none; }

/* ── Main Content ─────────────────────────────── */
.main-content {
    max-width: 1300px;
    margin: 1.5rem auto;
    padding: 0 1.5rem 2rem;
}

/* ── Global Mobile Styles ─────────────────────── */
@media (max-width: 600px) {
    /* Reduce page padding */
    .main-content {
        margin: 0.75rem auto;
        padding: 0 0.75rem 1.5rem;
    }

    /* Navbar: stack brand + links vertically, smaller text */
    .navbar {
        padding: 0.6rem 1rem;
        gap: 0.4rem;
    }
    .nav-brand { font-size: 1rem; }
    .nav-links  { gap: 0.3rem; }
    .nav-links a {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }
    .nav-user { font-size: 0.8rem; }

    /* Headings */
    h2 { font-size: 1.1rem; }
    h3 { font-size: 1rem; }

    /* Buttons full width on mobile */
    .form-actions {
        flex-direction: column;
    }
    .form-actions a,
    .form-actions button {
        width: 100%;
        text-align: center;
    }

    /* Cards: 2 per row on mobile */
    .cards { gap: 0.6rem; }
    .card  {
        min-width: calc(50% - 0.3rem);
        padding: 0.9rem 1rem;
    }
    .card-num { font-size: 1.4rem; }

    /* Tables: smaller text */
    .data-table { font-size: 0.78rem; }
    .data-table th,
    .data-table td { padding: 0.45rem 0.5rem; }

    /* Filter bar: full width inputs */
    .filter-bar { padding: 0.75rem; gap: 0.5rem; }
    .filter-bar input,
    .filter-bar select { max-width: 100%; }

    /* Payment table: scrollable */
    .payment-table { font-size: 0.82rem; }
    .payment-table th,
    .payment-table td { padding: 0.4rem 0.5rem; }

    /* Info table in view_sale */
    .info-table th,
    .info-table td { padding: 0.45rem 0.6rem; font-size: 0.85rem; }

    /* Date input: prevent overflow on mobile */
    input[type="date"] {
        width: 100%;
        min-width: 0;
        font-size: 0.9rem;
        padding: 0.55rem 0.5rem;
        appearance: none;
        -webkit-appearance: none;
    }

    /* Badges smaller */
    .badge { font-size: 0.7rem; padding: 0.15rem 0.5rem; }

    /* btn-sm touch friendly */
    .btn-sm { padding: 0.35rem 0.8rem; font-size: 0.78rem; }

    /* Alert */
    .alert { font-size: 0.85rem; }
}

/* ── Login / Register Form ────────────────────── */
.form-container {
    background: #ffffff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 420px;
    margin: 5vh auto;
}
h2  { margin-bottom: 1.2rem; color: #1e3a5f; }
h3  { color: #333; }
.sub-title { color: #777; margin-bottom: 1.5rem; font-size: 0.95rem; }
.section-title { margin: 1.5rem 0 0.75rem; color: #1e3a5f; border-bottom: 2px solid #e0e6ff; padding-bottom: 0.4rem; }

label { display: block; margin-bottom: 0.3rem; font-weight: 600; color: #555; font-size: 0.9rem; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    padding: 0.65rem 0.9rem;
    margin-bottom: 1rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
    background: #fff;
}
input:focus, select:focus { outline: none; border-color: #4f6ef7; }
.readonly-field { background: #f5f7ff !important; color: #1e3a5f; font-weight: 600; }
.req { color: #e74c3c; }

/* ── Buttons ──────────────────────────────────── */
button[type="submit"], .btn-primary {
    display: inline-block;
    padding: 0.65rem 1.4rem;
    background: #4f6ef7;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}
button[type="submit"]:hover, .btn-primary:hover { background: #3a55d4; }
.btn-primary.green  { background: #27ae60; }
.btn-primary.green:hover { background: #1e8449; }
.btn-primary.orange { background: #e67e22; }
.btn-primary.orange:hover { background: #ca6f1e; }
.btn-secondary {
    display: inline-block;
    padding: 0.65rem 1.4rem;
    background: #ecf0f1;
    color: #555;
    border-radius: 6px;
    font-size: 0.95rem;
    text-decoration: none;
    border: 1px solid #ccc;
}
.btn-secondary:hover { background: #dfe6e9; }
.btn-logout {
    display: inline-block;
    padding: 0.65rem 1.5rem;
    background: #e74c3c;
    color: #fff;
    border-radius: 6px;
    text-decoration: none;
}
.btn-sm {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 4px;
    font-size: 0.8rem;
    text-decoration: none;
    color: #fff;
    margin: 1px;
}
.btn-sm.blue     { background: #4f6ef7; }
.btn-sm.orange   { background: #e67e22; }
.btn-sm.red      { background: #e74c3c; }
.btn-sm.disabled { background: #ccc; color: #888; cursor: not-allowed; pointer-events: none; }

/* ── Alerts ───────────────────────────────────── */
.alert { padding: 0.8rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert.error   { background: #fdecea; color: #c0392b; border: 1px solid #f5c6cb; }
.alert.error ul { padding-left: 1.2rem; }
.alert.success { background: #eafaf1; color: #1e8449; border: 1px solid #a9dfbf; }

/* ── Dashboard Cards ──────────────────────────── */
.cards { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1.5rem 0; }
.card {
    flex: 1;
    min-width: 160px;
    padding: 1.2rem 1.5rem;
    border-radius: 10px;
    color: #fff;
    box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}
.card h3    { font-size: 0.9rem; opacity: 0.9; margin-bottom: 0.5rem; }
.card-num   { font-size: 1.8rem; font-weight: 700; }
.card span  { font-size: 0.8rem; opacity: 0.85; }
.card.blue   { background: linear-gradient(135deg,#4f6ef7,#3a55d4); }
.card.green  { background: linear-gradient(135deg,#27ae60,#1e8449); }
.card.orange { background: linear-gradient(135deg,#e67e22,#ca6f1e); }
.card.red    { background: linear-gradient(135deg,#e74c3c,#c0392b); }

/* ── Tables ───────────────────────────────────── */
.table-wrapper { overflow-x: auto; margin-top: 0.5rem; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th {
    background: #1e3a5f;
    color: #fff;
    padding: 0.65rem 0.8rem;
    text-align: left;
    white-space: nowrap;
}
.data-table td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid #e8eaf0;
    vertical-align: middle;
}
.data-table tbody tr:hover { background: #f5f7ff; }
.data-table tbody tr:nth-child(even) { background: #fafafa; }
.data-table tbody tr:nth-child(even):hover { background: #f0f3ff; }

/* ── Info Table (View) ────────────────────────── */
.info-table { width: 100%; border-collapse: collapse; }
.info-table th, .info-table td { padding: 0.65rem 0.9rem; border: 1px solid #e0e0e0; font-size: 0.95rem; }
.info-table th { background: #f5f7ff; color: #1e3a5f; width: 40%; font-weight: 600; }

/* ── Detail Grid (View Sale) ──────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1.5rem; }
@media (max-width: 768px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-card { background: #fff; border-radius: 10px; padding: 1.5rem; box-shadow: 0 2px 10px rgba(0,0,0,0.07); }
.detail-card h3 { margin-bottom: 1rem; color: #1e3a5f; }

/* ── Sale Form Grid ───────────────────────────── */
.sale-form { background: #fff; padding: 1.5rem; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.07); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-group { margin-bottom: 0.5rem; }
.form-actions { margin-top: 1.5rem; display: flex; gap: 1rem; flex-wrap: wrap; }

/* ── Filter Bar ───────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    background: #fff;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin: 1rem 0;
}
.filter-bar input, .filter-bar select {
    margin: 0;
    max-width: 220px;
    flex: 1;
    padding: 0.55rem 0.8rem;
}

/* ── Badges ───────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    background: #1e3a5f;
    color: #fff;
}
.mode-upi    { background: #6c5ce7; }
.mode-cash   { background: #00b894; }
.mode-cheque { background: #0984e3; }
.mode-neft   { background: #e17055; }

/* ── Colors ───────────────────────────────────── */
.text-red   { color: #e74c3c; font-weight: 600; }
.text-green { color: #27ae60; font-weight: 600; }
.text-blue  { color: #4f6ef7; }

/* ── Progress Bar ─────────────────────────────── */
.progress-bar  { background: #ecf0f1; border-radius: 10px; height: 14px; margin-top: 0.4rem; overflow: hidden; }
.progress-fill { background: linear-gradient(90deg,#27ae60,#2ecc71); height: 100%; border-radius: 10px; transition: width 0.4s; }

/* ── Switch Link ──────────────────────────────── */
.switch-link { text-align: center; margin-top: 1rem; font-size: 0.9rem; color: #666; }
.switch-link a { color: #4f6ef7; text-decoration: none; }
.switch-link a:hover { text-decoration: underline; }

/* ── Action Buttons Cell ──────────────────────── */
.action-btns { white-space: nowrap; }

/* ── Mobile: navbar user section ─────────────── */
@media (max-width: 480px) {
    .nav-user {
        width: 100%;
        font-size: 0.78rem;
        padding-top: 0.2rem;
    }
    .nav-brand { font-size: 0.95rem; }
}

/* ── Mobile: view_sale header row ────────────── */
@media (max-width: 600px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.6rem;
    }
    .page-header h2 { font-size: 1rem; word-break: break-word; }
    .page-header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

    /* sales.php custom range filter stacks */
    #customRange {
        flex-direction: column !important;
        align-items: flex-start !important;
        width: 100%;
    }
    #customRange input { width: 100% !important; }

    /* deposits.php inline total label wraps */
    .filter-bar .filter-total {
        margin-left: 0 !important;
        width: 100%;
        font-size: 0.82rem;
    }

    /* payment-table: label column narrower, inputs smaller */
    .payment-table td:first-child { font-size: 0.78rem; white-space: nowrap; }
    .payment-table input[type="number"] { min-width: 80px; }
    .inline-select { min-width: 70px; font-size: 0.78rem; padding: 0.35rem 0.4rem; }
}

/* ── Lock Badge (Edit Sale) ───────────────────── */
.lock-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    background: #fdecea;
    color: #c0392b;
    border: 1px solid #f5c6cb;
    border-radius: 20px;
    padding: 0.1rem 0.55rem;
    margin-left: 0.4rem;
    vertical-align: middle;
}

/* ── Payment Breakdown Table (Add / Edit Sale) ── */
.payment-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}
.payment-table th {
    background: #1e3a5f;
    color: #fff;
    padding: 0.65rem 1rem;
    text-align: left;
}
.payment-table td {
    padding: 0.55rem 0.8rem;
    border-bottom: 1px solid #e8eaf0;
    vertical-align: middle;
}
.payment-table input[type="number"] {
    margin: 0;
    padding: 0.45rem 0.7rem;
    width: 100%;
    min-width: 130px;
}
.payment-table .row-locked {
    background: #fafafa;
    color: #888;
}
.payment-table .row-locked td { color: #888; }

/* ── Inline Mode / Paid-To Selects ───────────── */
.inline-select {
    padding: 0.45rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.88rem;
    background: #fff;
    width: 100%;
    min-width: 110px;
    margin: 0;
}
.inline-select:disabled {
    background: #f5f7ff;
    color: #999;
    cursor: not-allowed;
}
