/*
 * app.css — Mekong Cruises Operator App
 * Centralized design system: tokens, layout, and shared components.
 * Load this file from includes/header.php.
 * Pages may still use $additional_styles for page-specific rules only.
 */

/* ═══════════════════════════════════════════════════════════
   1. DESIGN TOKENS
   ═══════════════════════════════════════════════════════════ */
:root {
    /* Brand */
    --brand:            #89624c;
    --brand-dark:       #5a3422;
    --brand-light:      #fdf0e8;
    --brand-focus:      rgba(118, 72, 46, 0.08);

    /* Backgrounds */
    --bg-page:          #f7f6f3;
    --bg-card:          #faf7f4;
    --bg-input:         #f9f9f8;
    --bg-input-hover:   #f5f0eb;

    /* Text */
    --text-primary:     #0f0e0d;
    --text-secondary:   #374151;
    --text-muted:       #6b7280;
    --text-faint:       #9ca3af;

    /* Borders / dividers */
    --divider:          #ede9e4;

    /* Semantic colours — warm-earth temperature family */
    --green-bg:         #eef4f0;    --green-text:   #2d6040;
    --yellow-bg:        #fdf6ec;    --yellow-text:  #9a5a16;
    --red-bg:           #fdf0ed;    --red-text:     #933018;
    --blue-bg:          #eef3f7;    --blue-text:    #2e5c7a;
    --purple-bg:        #f3eefb;    --purple-text:  #5c3d7a;
    --sky-bg:           #eef6f5;    --sky-text:     #1e6a60;
    --slate-bg:         #f2efec;    --slate-text:   #5d5550;

    /* Radius */
    --radius-xs:        3px;
    --radius-sm:        3px;
    --radius:           3px;
    --radius-lg:        3px;
    --radius-xl:        3px;
    --radius-2xl:       3px;
    --radius-full:      3px;

    /* Shadows */
    --shadow-sm:        none;
    --shadow:           0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
}


/* ═══════════════════════════════════════════════════════════
   2. GLOBAL RESET / BASE
   ═══════════════════════════════════════════════════════════ */
body {
    background: #f9f9f9 !important;
}

.content-wrapper {
    background: transparent !important;
    padding-top: 0 !important;
}


/* ═══════════════════════════════════════════════════════════
   3. PAGE HEADER
   ═══════════════════════════════════════════════════════════ */
.page-header {
    padding: 28px 36px 0;
    margin: 0 auto;
    background: #fff !important;
    border-color: var(--divider) !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    border-bottom-width: 1px !important;
}

.page-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 24px;
}
.page-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}
.page-icon {
    display: flex; align-items: center; justify-content: center;
    color: var(--brand); font-size: 18px;
    flex-shrink: 0;
    opacity: 0.75;
}
.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.035em;
    line-height: 1.2;
    font-family: 'FontTitle', sans-serif;
}
.page-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Info / stats bar (used inside .page-header) */
.info-bar {
    display: flex;
    border-top: 1px solid var(--divider);
}
.info-bar-item {
    flex: 1;
    padding: 16px 24px;
    border-right: 1px solid var(--divider);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.info-bar-item:last-child { border-right: none; }
.info-bar-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
}
.info-bar-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.info-bar-meta {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 1px;
}


/* ═══════════════════════════════════════════════════════════
   4. STAT CARDS  (standalone, outside header)
   ═══════════════════════════════════════════════════════════ */
.stat-card {
    background: #ffffff;
    border-radius: var(--radius-xl);
    padding: 18px 22px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid #ebe8e3;
    box-shadow: var(--shadow-sm);
}
.stat-icon {
    width: 38px; height: 38px;
    background: var(--brand-light);
    color: var(--brand);
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.stat-value {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}


/* ═══════════════════════════════════════════════════════════
   5. BUTTONS
   ═══════════════════════════════════════════════════════════ */
.btn-primary {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 18px; border-radius: var(--radius-lg);
    font-size: 0.8125rem; font-weight: 600; color: #fff;
    background: var(--brand); border: none; cursor: pointer;
    transition: background 0.12s; letter-spacing: 0.01em;
    text-decoration: none;
}
.btn-primary:hover { background: var(--brand-dark); color: #fff; }

.btn-secondary {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 16px; border-radius: var(--radius-lg);
    font-size: 0.8125rem; font-weight: 500; color: var(--text-secondary);
    background: var(--bg-input); border: 1px solid #e2e8f0; cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    text-decoration: none;
}
.btn-secondary:hover { background: var(--bg-input-hover); border-color: #cbd5e1; }

.btn-danger {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 16px; border-radius: var(--radius-lg);
    font-size: 0.8125rem; font-weight: 500; color: var(--red-text);
    background: var(--red-bg); border: 1px solid #fecaca; cursor: pointer;
    transition: background 0.12s;
    text-decoration: none;
}
.btn-danger:hover { background: #fee2e2; }

/* Small size modifier */
.btn-sm { padding: 5px 12px; font-size: 0.75rem; }

/* Icon-only action button (table rows etc.) */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border: none;
    background: transparent; color: var(--text-muted); border-radius: var(--radius-xs);
    cursor: pointer; transition: background 0.12s, color 0.12s; font-size: 11px;
}
.icon-btn:hover { background: var(--bg-input); color: var(--text-secondary); }
.icon-btn.danger:hover { background: var(--red-bg); color: #dc2626; }


/* ═══════════════════════════════════════════════════════════
   6. FORM ELEMENTS
   ═══════════════════════════════════════════════════════════ */
.f-input {
    width: 100%; padding: 8px 14px; border: 1px solid #ddd5ce;
    border-radius: var(--radius); font-size: 0.75rem; color: var(--text-secondary);
    background: var(--bg-input); transition: box-shadow 0.12s, border-color 0.12s;
    appearance: auto;
    font-family: inherit;
}
.f-input:focus {
    outline: none;
    border-color: var(--brand);
    color: var(--text-primary);
}
.f-input::placeholder { color: var(--text-muted); }

/* Select2 — match .f-input appearance */
.select2-container--default .select2-selection--single {
    height: auto !important;
    padding: 8px 14px !important;
    border: 1px solid #ddd5ce !important;
    border-radius: var(--radius) !important;
    background: var(--bg-input) !important;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: inherit;
    transition: box-shadow 0.12s;
    display: flex;
    align-items: center;
}
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--brand) !important;
    outline: none;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    padding: 0 !important;
    line-height: inherit;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: inherit;
}
.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--text-muted) !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100% !important;
    top: 0;
    right: 8px;
}
.select2-dropdown {
    border: 1px solid #ddd5ce !important;
    border-radius: var(--radius) !important;
    font-size: 0.75rem;
    font-family: inherit;
    color: var(--text-secondary);
    background: var(--bg-card) !important;
}
.select2-container--default .select2-results__option {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 6px 12px;
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--brand) !important;
    color: #fff;
}
.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #ddd5ce !important;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-family: inherit;
    padding: 4px 8px;
    background: var(--bg-input) !important;
    color: var(--text-primary);
}
.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--brand) !important;
    outline: none;
}

/* Standard form group (modals / detail pages) */
.form-group { margin-bottom: 12px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label {
    display: block; margin-bottom: 5px;
    font-weight: 600; font-size: 11px;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%; padding: 8px 14px;
    border: 1px solid #ddd5ce; border-radius: var(--radius);
    background: var(--bg-input); font-size: 0.875rem;
    color: var(--text-secondary); font-family: inherit;
    transition: box-shadow 0.12s, border-color 0.12s;
}
.form-group textarea { border-radius: var(--radius); resize: vertical; min-height: 72px; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--brand);
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.form-section { margin-bottom: 20px; }
.form-section-title {
    font-size: 0.8125rem; font-weight: 700;
    color: var(--brand); text-transform: uppercase; letter-spacing: .05em;
    margin-bottom: 12px; padding-bottom: 8px;
    border-bottom: 1px solid var(--divider);
}
.required { color: #ef4444; }


/* ═══════════════════════════════════════════════════════════
   7. TABLES
   ═══════════════════════════════════════════════════════════ */
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead { background: #f9f9f8; }
.tbl th {
    padding: 11px 16px; text-align: left;
    font-weight: 700; font-size: 11px;
    text-transform: uppercase; letter-spacing: .05em;
    color: #7a6154;
    border-bottom: 1px solid var(--divider);
}
.tbl td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--divider);
    font-size: 0.8125rem; color: var(--text-secondary);
}
.tbl tbody tr { transition: background 0.1s; }
.tbl tbody tr:hover { background: #f5f0eb; }

/* Pagination */
.page-btn {
    padding: 4px 9px; border: none; background: var(--bg-input);
    border-radius: var(--radius-sm); cursor: pointer;
    font-size: 0.75rem; color: var(--text-secondary);
    transition: all 0.12s; line-height: 1.5;
    font-family: inherit;
}
.page-btn:hover:not(:disabled) { background: var(--bg-input-hover); }
.page-btn.active { background: var(--brand); color: #fff; }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Loading / empty states */
.tbl-loading, .tbl-empty {
    text-align: center; padding: 60px 20px;
    color: var(--text-muted); font-size: 0.8125rem;
}
.tbl-loading i, .tbl-empty i { font-size: 1.75rem; display: block; margin-bottom: 10px; opacity: 0.3; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; opacity: 0.4; }


/* ═══════════════════════════════════════════════════════════
   8. BADGES
   ═══════════════════════════════════════════════════════════ */

/* Booking / payment status */
.status-badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: var(--radius-full);
    font-size: 11px; font-weight: 600; text-transform: capitalize;
    letter-spacing: .01em;
}
.status-badge.pending   { background: var(--yellow-bg); color: var(--yellow-text); }
.status-badge.confirmed { background: var(--green-bg);  color: var(--green-text); }
.status-badge.cancelled { background: var(--red-bg);    color: var(--red-text); }
.status-badge.completed { background: var(--sky-bg);    color: var(--sky-text); }
.status-badge.paid      { background: var(--green-bg);  color: var(--green-text); }
.status-badge.unpaid    { background: var(--red-bg);    color: var(--red-text); }
.status-badge.partial   { background: var(--yellow-bg); color: var(--yellow-text); }

/* Departure status */
.dep-badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: var(--radius-full);
    font-size: 11px; font-weight: 600; text-transform: capitalize;
    letter-spacing: .01em;
}
.dep-badge.scheduled { background: var(--blue-bg);   color: var(--blue-text); }
.dep-badge.confirmed { background: var(--green-bg);  color: var(--green-text); }
.dep-badge.cancelled { background: var(--red-bg);    color: var(--red-text); }
.dep-badge.departed  { background: var(--purple-bg); color: var(--purple-text); }
.dep-badge.completed { background: var(--slate-bg);  color: var(--slate-text); }
.dep-badge.unknown   { background: var(--bg-input);  color: var(--text-muted); }

/* Generic pill badge */
.badge {
    display: inline-block; padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.badge-active   { background: var(--green-bg);  color: var(--green-text); }
.badge-inactive { background: var(--slate-bg);  color: var(--slate-text); }
.badge-blocked  { background: var(--red-bg);    color: var(--red-text); }
.badge-pending  { background: var(--yellow-bg); color: var(--yellow-text); }


/* ═══════════════════════════════════════════════════════════
   9. MODAL
   ═══════════════════════════════════════════════════════════ */
.modal {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.45); z-index: 1000; overflow-y: auto;
}
.modal.active { display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-content {
    background: #ffffff; border-radius: var(--radius-xl);
    width: 100%; max-width: 800px; max-height: 90vh;
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; overflow: hidden;
}
/* When a <form> is the direct flex child (wraps body + actions), it must relay flex layout */
.modal-content > form {
    display: flex; flex-direction: column; flex: 1; overflow: hidden; min-height: 0;
}
.modal-header {
    padding: 16px 20px; border-bottom: 1px solid var(--divider);
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
}
.modal-header h2 { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin: 0; }
.modal-close {
    background: none; border: none; font-size: 20px;
    cursor: pointer; color: var(--text-muted); line-height: 1; padding: 0;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px; flex: 1; overflow-y: auto; min-height: 0; }
.modal-actions {
    padding: 16px 20px; border-top: 1px solid var(--divider);
    display: flex; justify-content: flex-end; gap: 8px;
    flex-shrink: 0;
}
/* alias for pages still using modal-footer */
.modal-footer {
    padding: 16px 20px; border-top: 1px solid var(--divider);
    display: flex; justify-content: flex-end; gap: 8px;
    flex-shrink: 0;
}
.modal-body.p-0 { padding: 0; }

/* ── Modal sections (ag-section pattern — matches agencies.php reference design) ── */
.ag-section { padding: 14px 20px 16px; }
.ag-section + .ag-section { border-top: 1px solid var(--divider); }
.ag-section-header { display: flex; align-items: center; gap: 8px; margin-bottom: 11px; }
.ag-section-icon {
    width: 24px; height: 24px; border-radius: var(--radius-sm);
    background: var(--brand-light); color: var(--brand);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; flex-shrink: 0;
}
.ag-section-title { font-size: .6875rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .07em; }
.ag-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ag-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ag-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ag-section .form-group { margin-bottom: 0; }
.ag-section .form-group small { font-size: 11px; color: var(--text-faint); margin-top: 3px; display: block; line-height: 1.4; }
/* ensure .f-input font-size wins over the .form-group input rule */
.form-group .f-input { font-size: 0.75rem; }


/* ═══════════════════════════════════════════════════════════
   10. SPINNER
   ═══════════════════════════════════════════════════════════ */
.spinner {
    display: inline-block; width: 18px; height: 18px;
    border: 2px solid #e2e8f0; border-top-color: var(--brand);
    border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ═══════════════════════════════════════════════════════════
   11. CARD / CONTENT PANELS
   ═══════════════════════════════════════════════════════════ */
.card {
    background: #ffffff;
    border-radius: var(--radius-xl);
    border: 1px solid #ebe8e3;
    box-shadow: var(--shadow-sm);
}
.card-body { padding: 20px; }
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--divider);
    display: flex; align-items: center; justify-content: space-between;
}
.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--divider);
    background: #faf9f7;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ── Warm override for residual Tailwind cold classes ── */
.border-slate-100, .border-slate-200 { border-color: var(--divider) !important; }
.text-slate-500 { color: var(--text-muted) !important; }
.bg-slate-50 { background: var(--bg-input) !important; }

/* ── Shared layout wrappers ── */
.filter-bar {
    background: #ffffff;
    border: 1px solid var(--divider);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}
.table-wrap {
    background: #ffffff;
    border: 1px solid var(--divider);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* ── Focus rings ── */
:focus-visible {
    outline: 2px solid rgba(137, 98, 76, 0.45);
    outline-offset: 2px;
    border-radius: 3px;
}

/* ── Thin warm scrollbars (WebKit) ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(137, 98, 76, 0.22); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(137, 98, 76, 0.42); }
