/* ============================================================================
   PARAKKADAN KUDUMBA KOOTTAIMA - MEMBER MASTER MODULE STYLES
   Template Design: Royal Midnight Emerald & Rich Gold (#031d16 & #d4af37)
============================================================================ */

:root {
    --mm-bg-main: #031d16;
    --mm-bg-card: linear-gradient(145deg, rgba(10, 46, 35, 0.92), rgba(4, 21, 16, 0.96));
    --mm-bg-header: linear-gradient(135deg, #0d3b2c 0%, #164e3b 100%);
    --mm-gold: #d4af37;
    --mm-gold-light: #f3e5ab;
    --mm-gold-hover: #b89628;
    --mm-text: #f0f4f1;
    --mm-text-muted: #94a3b8;
    --mm-border: rgba(212, 175, 55, 0.35);
    --mm-blue-accent: #5bc0de;
    --mm-danger: #ef4444;
    --mm-success: #10b981;
}

.mm-container {
    background: radial-gradient(circle at top center, #072a20 0%, #031d16 60%, #010d0a 100%);
    color: var(--mm-text);
    min-height: 100vh;
    padding: 28px 32px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.mm-header-title {
    color: var(--mm-gold);
    font-weight: 800;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--mm-border);
    padding-bottom: 14px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    letter-spacing: 0.5px;
}

/* Glassmorphism Panels */
.mm-card {
    background: var(--mm-bg-card);
    border: 1px solid var(--mm-border);
    border-radius: 14px;
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5), inset 0 1px 0 0 rgba(212, 175, 55, 0.2);
    backdrop-filter: blur(16px);
    margin-bottom: 28px;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.mm-card-header {
    background: var(--mm-bg-header);
    color: var(--mm-gold-light);
    padding: 16px 24px;
    font-weight: 700;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1.5px solid var(--mm-border);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    letter-spacing: 0.5px;
}

.mm-card-body {
    padding: 24px;
}

/* Form Controls */
.mm-form-label {
    color: var(--mm-gold-light) !important;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
    letter-spacing: 0.3px;
}

.mm-form-label .req {
    color: var(--mm-danger);
}

.mm-input, .mm-select, .mm-textarea {
    background-color: rgba(4, 21, 16, 0.85) !important;
    border: 1px solid var(--mm-border) !important;
    color: #ffffff !important;
    border-radius: 8px !important;
    padding: 10px 14px !important;
    font-size: 0.92rem !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Placeholder text — bright and readable */
.mm-container ::placeholder,
.mm-input::placeholder,
.mm-textarea::placeholder,
.mm-table input::placeholder {
    color: #94a3b8 !important;
    opacity: 0.85 !important;
}

.mm-container .text-muted {
    color: #cbd5e1 !important;
}

/* Calendar picker icon contrast */
.mm-container input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8) sepia(1) saturate(5) hue-rotate(350deg) !important;
    cursor: pointer;
}

/* Select dropdown option text */
.mm-select option {
    background-color: #0d3b2c !important;
    color: #f3e5ab !important;
}

.mm-input:focus, .mm-select:focus, .mm-textarea:focus {
    border-color: var(--mm-gold) !important;
    box-shadow: 0 0 0 3.5px rgba(212, 175, 55, 0.3), inset 0 2px 4px rgba(0,0,0,0.2) !important;
    outline: none !important;
    color: #ffffff !important;
    background-color: rgba(8, 35, 27, 0.95) !important;
}

.mm-input[readonly] {
    background-color: rgba(15, 56, 42, 0.6) !important;
    color: var(--mm-gold) !important;
    font-weight: 700 !important;
    cursor: not-allowed;
}

/* General label override for Bootstrap conflict */
.mm-container label,
.mm-container .form-label {
    color: var(--mm-gold-light) !important;
}

/* Input text inside inline grid rows */
.mm-table input.form-control,
.mm-table select.form-select,
.mm-table input.mm-input,
.mm-table select.mm-select {
    background-color: rgba(4, 21, 16, 0.9) !important;
    color: #ffffff !important;
    border: 1px solid rgba(212, 175, 55, 0.4) !important;
    border-radius: 6px !important;
}

.mm-table input.form-control::placeholder {
    color: rgba(243, 229, 171, 0.6) !important;
}

/* Detail Sub-Grid Table */
.mm-grid-table-wrapper {
    border: 2px solid var(--mm-gold);
    border-radius: 12px;
    overflow-x: auto;
    background-color: rgba(4, 21, 16, 0.6);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.mm-grid-header {
    background: linear-gradient(135deg, #1b4958 0%, #0d3b2c 100%);
    color: var(--mm-gold-light);
    padding: 14px 20px;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--mm-gold);
    letter-spacing: 0.5px;
}

.mm-table {
    width: 100%;
    margin-bottom: 0;
    color: var(--mm-text);
    border-collapse: collapse;
    min-width: 900px;
}

.mm-table thead {
    background: linear-gradient(135deg, #164e3b 0%, #0d3b2c 100%);
    color: var(--mm-gold-light);
    font-weight: 700;
    border-bottom: 2px solid var(--mm-gold);
}

.mm-table th, .mm-table td {
    padding: 12px 14px;
    vertical-align: middle;
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
}

.mm-table tbody tr:hover {
    background-color: rgba(212, 175, 55, 0.12);
}

/* Buttons */
.btn-mm-gold {
    background: linear-gradient(135deg, #d4af37 0%, #b89628 100%);
    color: #041510;
    font-weight: 800;
    border: none;
    padding: 11px 28px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.35);
    letter-spacing: 0.5px;
    transition: all 0.25s ease;
}

.btn-mm-gold:hover {
    background: linear-gradient(135deg, #f3e5ab 0%, #d4af37 100%);
    color: #041510;
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(212, 175, 55, 0.5);
}

.btn-mm-outline {
    background-color: transparent;
    color: var(--mm-gold-light);
    border: 1.5px solid var(--mm-gold);
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.25s ease;
}

.btn-mm-outline:hover {
    background-color: rgba(212, 175, 55, 0.2);
    color: #ffffff;
    border-color: var(--mm-gold-light);
}

/* Tree Canvas Modal Upgrades */
.minimal-tree-card {
    border: 2px solid #d4af37 !important;
    border-radius: 12px !important;
    background: linear-gradient(180deg, #0f172a 0%, #090d16 100%) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6), 0 0 15px rgba(212, 175, 55, 0.2) !important;
    transition: transform 0.25s ease, box-shadow 0.25s ease !important;
}

.minimal-tree-card:hover {
    transform: translateY(-5px) scale(1.03) !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.8), 0 0 25px rgba(212, 175, 55, 0.45) !important;
}

/* Loading Overlay */
.mm-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 29, 22, 0.88);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: var(--mm-gold);
}

/* Toast Alerts Container */
#mm-toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
}

.mm-toast {
    background: linear-gradient(135deg, #0d3b2c 0%, #041510 100%);
    border: 1.5px solid var(--mm-border);
    color: #ffffff;
    padding: 16px 20px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    gap: 14px;
    animation: slideIn 0.3s ease forwards;
}

.mm-toast.success {
    border-left: 5px solid var(--mm-success);
}

.mm-toast.error {
    border-left: 5px solid var(--mm-danger);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============================================================================
   RESPONSIVE MOBILE — FULL REWRITE
   Target: 344px (Android 11 Samsung Galaxy)
   Strategy:
     1. No horizontal page scroll (html/body locked)
     2. Bootstrap col-md-* already stacks on mobile (col-12 fallback in HTML)
     3. Family Members table: hide 4 cols, keep 5 cols with fixed widths
     4. tfoot input row stays as normal table row (no block hacks)
     5. Households table: hide 3 cols, keep 3 cols with auto layout
     6. All inline min-width overridden via !important
   ============================================================================ */

html, body {
    max-width: 100vw !important;
    overflow-x: hidden !important;
}

/* ── MOBILE BREAKPOINT ──────────────────────────────────────────────────── */
@media (max-width: 768px) {

    /* Page wrapper */
    .mm-container {
        padding: 8px 6px !important;
        overflow-x: hidden !important;
    }

    /* Page title */
    .mm-header-title {
        font-size: 1rem !important;
        gap: 6px !important;
        margin-bottom: 10px !important;
        padding-bottom: 8px !important;
        flex-wrap: wrap !important;
    }

    /* Cards */
    .mm-card {
        border-radius: 10px !important;
        margin-bottom: 12px !important;
    }

    .mm-card-header {
        padding: 10px 12px !important;
        font-size: 0.85rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .mm-card-body {
        padding: 10px 8px !important;
    }

    /* ── SEARCH + TOOLBAR ── */
    .mm-toolbar-buttons {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
        width: 100% !important;
    }

    .mm-toolbar-buttons .btn {
        width: 100% !important;
        padding: 8px 4px !important;
        font-size: 0.78rem !important;
        justify-content: center !important;
        white-space: nowrap !important;
    }

    /* Search input placeholder shorter on mobile */
    #mm-search-input::placeholder {
        font-size: 0.72rem !important;
    }

    /* ── FORM FIELDS — stack all cols to full width ── */
    .mm-form-label {
        font-size: 0.78rem !important;
        margin-bottom: 2px !important;
    }

    .mm-input,
    .mm-select,
    .mm-textarea {
        padding: 7px 8px !important;
        font-size: 0.8rem !important;
    }

    /* Photo preview box: center on mobile */
    #head-photo-preview-box {
        align-items: center !important;
        width: 100% !important;
    }

    /* ── GRID HEADER (Family Members section) ── */
    .mm-grid-header {
        padding: 8px 10px !important;
        font-size: 0.8rem !important;
    }

    /* ── FAMILY MEMBERS TABLE (Touch Scrollable) ────────────────── */
    .mm-grid-table-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
        border-radius: 8px;
        margin-bottom: 10px;
    }

    .mm-grid-table-wrapper .mm-table {
        min-width: 680px !important;
        width: max-content !important;
        table-layout: auto !important;
    }

    .mm-grid-table-wrapper .mm-table th,
    .mm-grid-table-wrapper .mm-table td {
        padding: 6px 6px !important;
        font-size: 0.75rem !important;
        white-space: nowrap !important;
        vertical-align: middle !important;
    }

    .mm-grid-table-wrapper .mm-table tfoot input,
    .mm-grid-table-wrapper .mm-table tfoot select {
        padding: 5px 6px !important;
        font-size: 0.75rem !important;
        min-width: 90px !important;
    }

    #btn-add-grid-row {
        padding: 6px 10px !important;
        font-size: 0.75rem !important;
        white-space: nowrap !important;
    }

    /* ── REGISTERED HOUSEHOLDS TABLE ────────────────────── */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
        border-radius: 8px;
    }

    .table-responsive .mm-table {
        min-width: 580px !important;
        width: 100% !important;
    }

    .table-responsive .mm-table th,
    .table-responsive .mm-table td {
        padding: 6px 4px !important;
        font-size: 0.72rem !important;
        word-break: break-word !important;
        vertical-align: middle !important;
    }

    /* Action buttons: stack vertically */
    .table-responsive .mm-table tbody tr td:nth-child(6) > div {
        flex-direction: column !important;
        gap: 3px !important;
    }

    .table-responsive .mm-table tbody tr td:nth-child(6) .btn {
        width: 100% !important;
        font-size: 0.65rem !important;
        padding: 3px 5px !important;
    }

    /* ── TOAST ── */
    #mm-toast-container {
        top: 10px !important;
        right: 6px !important;
        left: 6px !important;
        max-width: calc(100vw - 12px) !important;
    }
}

/* ── EXTRA SMALL (< 400px) ──────────────────────────────────────────────── */
@media (max-width: 400px) {
    .mm-container {
        padding: 6px 4px !important;
    }

    .mm-header-title {
        font-size: 0.88rem !important;
    }

    .mm-card-body {
        padding: 8px 4px !important;
    }

    .mm-grid-table-wrapper .mm-table th,
    .mm-grid-table-wrapper .mm-table td {
        font-size: 0.62rem !important;
        padding: 4px 2px !important;
    }

    .mm-grid-table-wrapper .mm-table tfoot input,
    .mm-grid-table-wrapper .mm-table tfoot select {
        font-size: 0.58rem !important;
    }

    #btn-add-grid-row {
        font-size: 0.55rem !important;
    }
}


html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    /* Container */
    .mm-container {
        padding: 10px 8px !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    /* Page title */
    .mm-header-title {
        font-size: 1.1rem !important;
        gap: 8px !important;
        margin-bottom: 12px !important;
        padding-bottom: 10px !important;
    }

    /* Cards */
    .mm-card {
        border-radius: 10px !important;
        margin-bottom: 14px !important;
    }

    .mm-card-header {
        padding: 10px 12px !important;
        font-size: 0.9rem !important;
    }

    .mm-card-body {
        padding: 10px 8px !important;
    }

    /* ── Search + Action Toolbar ── */
    /* Search takes full width, buttons wrap below as 2x2 grid */
    .mm-toolbar-buttons {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
        width: 100% !important;
        padding-top: 6px !important;
    }

    .mm-toolbar-buttons .btn {
        width: 100% !important;
        padding: 8px 4px !important;
        font-size: 0.8rem !important;
        justify-content: center !important;
    }

    /* ── Form fields ── */
    .mm-form-label {
        font-size: 0.8rem !important;
        margin-bottom: 3px !important;
    }

    .mm-input, .mm-select, .mm-textarea {
        padding: 7px 9px !important;
        font-size: 0.82rem !important;
    }

    /* ── Grid Header (Family Members) ── */
    .mm-grid-header {
        flex-direction: row !important;
        justify-content: space-between !important;
        gap: 4px !important;
        padding: 8px 10px !important;
        font-size: 0.82rem !important;
    }

    /* ── ZERO-SCROLLING MOBILE TABLES & CARDS ────────────────── */
    .mm-grid-table-wrapper,
    .table-responsive {
        overflow-x: hidden !important;
        max-width: 100% !important;
        width: 100% !important;
        display: block !important;
    }

    .mm-grid-table-wrapper .mm-table,
    .table-responsive .mm-table {
        min-width: 0 !important;
        width: 100% !important;
        display: block !important;
    }

    /* Hide standard table headers on mobile */
    .mm-grid-table-wrapper .mm-table thead,
    .table-responsive .mm-table thead {
        display: none !important;
    }

    .mm-grid-table-wrapper .mm-table tbody,
    .table-responsive .mm-table tbody {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        width: 100% !important;
    }

    /* Each table row becomes a clean, stylish mobile card */
    .mm-grid-table-wrapper .mm-table tbody tr,
    .table-responsive .mm-table tbody tr {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        padding: 14px 12px !important;
        background: linear-gradient(135deg, rgba(15, 56, 42, 0.85), rgba(4, 21, 16, 0.95)) !important;
        border: 1.5px solid rgba(212, 175, 55, 0.35) !important;
        border-radius: 12px !important;
        gap: 8px !important;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35) !important;
        box-sizing: border-box !important;
    }

    /* Table cells inside card */
    .mm-grid-table-wrapper .mm-table tbody tr td,
    .table-responsive .mm-table tbody tr td {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        padding: 4px 0 !important;
        border: none !important;
        border-bottom: 1px dashed rgba(212, 175, 55, 0.15) !important;
        font-size: 0.84rem !important;
        color: #f0f4f1 !important;
        word-break: break-word !important;
        white-space: normal !important;
    }

    .mm-grid-table-wrapper .mm-table tbody tr td:last-child,
    .table-responsive .mm-table tbody tr td:last-child {
        border-bottom: none !important;
        padding-top: 8px !important;
    }

    /* Field labels for Registered Households Card */
    .table-responsive .mm-table tbody tr td:nth-child(1)::before { content: "Membership No:"; font-weight: 700; color: var(--mm-gold); }
    .table-responsive .mm-table tbody tr td:nth-child(2)::before { content: "Head of House:"; font-weight: 700; color: var(--mm-gold-light); }
    .table-responsive .mm-table tbody tr td:nth-child(3)::before { content: "Zone / Division:"; font-weight: 600; color: #a2b5a8; }
    .table-responsive .mm-table tbody tr td:nth-child(4)::before { content: "Phone Number:"; font-weight: 600; color: #a2b5a8; }
    .table-responsive .mm-table tbody tr td:nth-child(5)::before { content: "Membership Date:"; font-weight: 600; color: #a2b5a8; }
    .table-responsive .mm-table tbody tr td:nth-child(6)::before { content: "Actions:"; font-weight: 700; color: var(--mm-gold); }

    /* Action buttons in Household Card — full width flex grid */
    .table-responsive .mm-table tbody tr td:nth-child(6) > div {
        display: flex !important;
        width: 100% !important;
        gap: 6px !important;
        justify-content: flex-end !important;
    }

    .table-responsive .mm-table tbody tr td:nth-child(6) .btn {
        flex: 1 1 auto !important;
        padding: 6px 10px !important;
        font-size: 0.78rem !important;
        font-weight: 700 !important;
        justify-content: center !important;
        text-align: center !important;
    }

    /* Field labels for Family Members Grid Cards */
    .mm-grid-table-wrapper .mm-table tbody tr td:nth-child(1)::before { content: "Photo:"; font-weight: 700; color: var(--mm-gold); }
    .mm-grid-table-wrapper .mm-table tbody tr td:nth-child(2)::before { content: "Member Name:"; font-weight: 700; color: #ffffff; }
    .mm-grid-table-wrapper .mm-table tbody tr td:nth-child(3)::before { content: "Relation:"; font-weight: 600; color: var(--mm-gold-light); }
    .mm-grid-table-wrapper .mm-table tbody tr td:nth-child(4)::before { content: "Belongs To:"; font-weight: 600; color: #a2b5a8; }
    .mm-grid-table-wrapper .mm-table tbody tr td:nth-child(5)::before { content: "Status:"; font-weight: 600; color: #a2b5a8; }
    .mm-grid-table-wrapper .mm-table tbody tr td:nth-child(6)::before { content: "Date of Death:"; font-weight: 600; color: #a2b5a8; }
    .mm-grid-table-wrapper .mm-table tbody tr td:nth-child(7)::before { content: "Date of Cessation:"; font-weight: 600; color: #a2b5a8; }
    .mm-grid-table-wrapper .mm-table tbody tr td:nth-child(8)::before { content: "Remarks:"; font-weight: 600; color: #a2b5a8; }
    .mm-grid-table-wrapper .mm-table tbody tr td:nth-child(9)::before { content: "Action:"; font-weight: 700; color: var(--mm-gold); }

    /* Family Members Form tfoot (Add New Row form) on Mobile */
    .mm-grid-table-wrapper .mm-table tfoot {
        display: block !important;
        width: 100% !important;
        margin-top: 14px !important;
    }

    .mm-grid-table-wrapper .mm-table tfoot tr {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        padding: 14px 12px !important;
        background: linear-gradient(135deg, rgba(20, 70, 53, 0.95), rgba(6, 30, 23, 0.98)) !important;
        border: 2px solid #5bc0de !important;
        border-radius: 12px !important;
        gap: 10px !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
        box-sizing: border-box !important;
    }

    .mm-grid-table-wrapper .mm-table tfoot td {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
        border: none !important;
    }

    .mm-grid-table-wrapper .mm-table tfoot .mm-input,
    .mm-grid-table-wrapper .mm-table tfoot .mm-select,
    .mm-grid-table-wrapper .mm-table tfoot input,
    .mm-grid-table-wrapper .mm-table tfoot select {
        width: 100% !important;
        min-width: 0 !important;
        padding: 9px 12px !important;
        font-size: 0.85rem !important;
        border-radius: 8px !important;
    }

    #btn-add-grid-row {
        width: 100% !important;
        padding: 12px !important;
        font-size: 0.92rem !important;
        font-weight: 700 !important;
        border-radius: 8px !important;
        margin-top: 4px !important;
        justify-content: center !important;
    }

    /* ── Form Fields Stack on Mobile ── */
    .col-6,
    .col-md-3,
    .col-md-4,
    .col-md-6 {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* ── Bottom Save Button ── */
    #mm-btn-save-bottom {
        width: 100% !important;
        justify-content: center !important;
        padding: 12px 16px !important;
        font-size: 0.95rem !important;
    }

    /* ── Toast ── */
    #mm-toast-container {
        top: 10px !important;
        right: 8px !important;
        left: 8px !important;
        max-width: calc(100vw - 16px) !important;
    }
}

@media (max-width: 480px) {
    .mm-container {
        padding: 6px 4px !important;
    }

    .mm-card-body {
        padding: 8px 6px !important;
    }
}


