/* ============================================================
   Panchostack — Core Styles
   Universal styles shared by ALL layouts (mobile + web)
   ============================================================ */

/* ----- Theme Variables ----- */
:root {
    --accent: #0D9488;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-elevated: #ffffff;
    --surface: #ffffff;
    --surface-hover: #f9fafb;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-tertiary: #6b7280;
    --text-muted: #9ca3af;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.14);
    --skeleton-from: #f0f0f0;
    --skeleton-via: #e0e0e0;
    --overlay: rgba(0,0,0,0.4);
    --nav-bg: #ffffff;
    --sheet-bg: #f3f4f6;
    --input-bg: #ffffff;
}

html[data-theme="dark"] {
    --bg-primary: #0f0f0f;
    --bg-secondary: #121212;
    --bg-tertiary: #2a2a2a;
    --bg-elevated: #222222;
    --surface: #1e1e1e;
    --surface-hover: #2a2a2a;
    --border: #363636;
    --border-light: #2a2a2a;
    --text-primary: #f0f0f0;
    --text-secondary: #d4d4d4;
    --text-tertiary: #a0a0a0;
    --text-muted: #777777;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);
    --skeleton-from: #252525;
    --skeleton-via: #2e2e2e;
    --overlay: rgba(0,0,0,0.6);
    --nav-bg: #121212;
    --sheet-bg: #161616;
    --input-bg: #252525;
}

/* ----- Reset & Base ----- */
*, *::before, *::after { box-sizing: border-box; }
body {
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.select-none { -webkit-user-select: none; user-select: none; }
input, textarea, [contenteditable] {
    -webkit-user-select: text !important;
    user-select: text !important;
}

/* ----- Tailwind Dark Overrides ----- */
html[data-theme="dark"] .bg-white { background: var(--surface) !important; }
html[data-theme="dark"] .bg-gray-50 { background: var(--bg-tertiary) !important; }
html[data-theme="dark"] .bg-gray-100 { background: var(--bg-tertiary) !important; }
html[data-theme="dark"] .text-gray-900 { color: var(--text-primary) !important; }
html[data-theme="dark"] .text-gray-800 { color: var(--text-primary) !important; }
html[data-theme="dark"] .text-gray-700 { color: var(--text-secondary) !important; }
html[data-theme="dark"] .text-gray-600 { color: var(--text-tertiary) !important; }
html[data-theme="dark"] .text-gray-500 { color: var(--text-tertiary) !important; }
html[data-theme="dark"] .text-gray-400 { color: var(--text-muted) !important; }
html[data-theme="dark"] .text-gray-300 { color: var(--text-muted) !important; }
html[data-theme="dark"] .border-gray-200 { border-color: var(--border) !important; }
html[data-theme="dark"] .border-gray-100 { border-color: var(--border-light) !important; }
html[data-theme="dark"] .border-gray-50 { border-color: var(--border-light) !important; }
html[data-theme="dark"] .divide-gray-100 > * + * { border-color: var(--border-light) !important; }
html[data-theme="dark"] .shadow-lg { box-shadow: var(--shadow-lg) !important; }
html[data-theme="dark"] .shadow-xl { box-shadow: var(--shadow-lg) !important; }
html[data-theme="dark"] .ring-accent { --tw-ring-color: var(--accent) !important; }
html[data-theme="dark"] .border-t { border-color: var(--border) !important; }
html[data-theme="dark"] .border-b { border-color: var(--border) !important; }

/* Dark toast overrides */
html[data-theme="dark"] .bg-green-50 { background: #052e16 !important; }
html[data-theme="dark"] .bg-red-50 { background: #450a0a !important; }
html[data-theme="dark"] .bg-blue-50 { background: #172554 !important; }
html[data-theme="dark"] .bg-yellow-50 { background: #422006 !important; }
html[data-theme="dark"] .bg-amber-50 { background: #451a03 !important; }
html[data-theme="dark"] .border-green-200 { border-color: #166534 !important; }
html[data-theme="dark"] .border-red-200 { border-color: #991b1b !important; }
html[data-theme="dark"] .border-blue-200 { border-color: #1e40af !important; }
html[data-theme="dark"] .border-yellow-200 { border-color: #854d0e !important; }
html[data-theme="dark"] .border-amber-200 { border-color: #92400e !important; }
html[data-theme="dark"] .text-green-800 { color: #86efac !important; }
html[data-theme="dark"] .text-red-800 { color: #fca5a5 !important; }
html[data-theme="dark"] .text-blue-800 { color: #93c5fd !important; }
html[data-theme="dark"] .text-yellow-800 { color: #fde68a !important; }
html[data-theme="dark"] .text-amber-800 { color: #fcd34d !important; }
html[data-theme="dark"] .text-amber-900 { color: #fcd34d !important; }
html[data-theme="dark"] .text-amber-600 { color: #fcd34d !important; }
html[data-theme="dark"] .bg-green-100 { background: #052e16 !important; }
html[data-theme="dark"] .bg-blue-100 { background: #172554 !important; }
html[data-theme="dark"] .text-green-700 { color: #86efac !important; }
html[data-theme="dark"] .text-blue-600 { color: #93c5fd !important; }
html[data-theme="dark"] .text-red-400 { color: #f87171 !important; }
html[data-theme="dark"] .text-red-500 { color: #f87171 !important; }
html[data-theme="dark"] .text-red-600 { color: #fca5a5 !important; }
html[data-theme="dark"] .border-dashed { border-color: var(--border) !important; }

/* Dark badge overrides */
html[data-theme="dark"] .badge-pending,
html[data-theme="dark"] .badge-partial   { background: #422006; color: #fcd34d; }
html[data-theme="dark"] .badge-paid      { background: #052e16; color: #6ee7b7; }
html[data-theme="dark"] .badge-overdue,
html[data-theme="dark"] .badge-unpaid    { background: #450a0a; color: #fca5a5; }
html[data-theme="dark"] .badge-occupied  { background: #052e16; color: #6ee7b7; }
html[data-theme="dark"] .badge-vacant    { background: #422006; color: #fcd34d; }
html[data-theme="dark"] .badge-ticket-submitted    { background: #422006; color: #fcd34d; }
html[data-theme="dark"] .badge-ticket-acknowledged { background: #172554; color: #93c5fd; }
html[data-theme="dark"] .badge-ticket-in_progress  { background: #2e1065; color: #c4b5fd; }
html[data-theme="dark"] .badge-ticket-completed    { background: #052e16; color: #6ee7b7; }
html[data-theme="dark"] .badge-ticket-rejected     { background: #450a0a; color: #fca5a5; }
html[data-theme="dark"] .badge-priority-low    { background: var(--bg-tertiary); color: var(--text-secondary); }
html[data-theme="dark"] .badge-priority-medium { background: #422006; color: #fcd34d; }
html[data-theme="dark"] .badge-priority-high   { background: #431407; color: #fdba74; }
html[data-theme="dark"] .badge-priority-urgent { background: #450a0a; color: #fca5a5; }

/* ----- Buttons ----- */
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; min-height: 52px; padding: 14px 24px;
    background: var(--accent); color: white;
    border: none; border-radius: 16px;
    font-size: 16px; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: transform 0.1s, opacity 0.15s;
    font-family: 'DM Sans', sans-serif;
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.5; pointer-events: none; }

.btn-secondary {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; min-height: 48px; padding: 12px 24px;
    background: var(--bg-primary); color: var(--accent);
    border: 2px solid var(--accent); border-radius: 16px;
    font-size: 15px; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: transform 0.1s;
    font-family: 'DM Sans', sans-serif;
}
.btn-secondary:active { transform: scale(0.97); }

.btn-danger {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; min-height: 48px; padding: 12px 24px;
    background: #FEE2E2; color: #DC2626;
    border: none; border-radius: 16px;
    font-size: 15px; font-weight: 600;
    cursor: pointer; transition: transform 0.1s;
    font-family: 'DM Sans', sans-serif;
}
html[data-theme="dark"] .btn-danger { background: #450a0a; color: #fca5a5; }
.btn-danger:active { transform: scale(0.97); }

.btn-ghost {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; background: transparent; color: var(--accent);
    border: none; border-radius: 12px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: background 0.15s;
    font-family: 'DM Sans', sans-serif;
}
.btn-ghost:hover { background: var(--surface-hover); }

.btn-primary-sm {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; min-height: 36px;
    background: var(--accent); color: white;
    border: none; border-radius: 12px;
    font-size: 13px; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: transform 0.1s;
    white-space: nowrap;
    font-family: 'DM Sans', sans-serif;
}
.btn-primary-sm:active { transform: scale(0.97); }

/* ----- Cards ----- */
.card {
    background: var(--surface); border-radius: 16px;
    box-shadow: var(--shadow-sm);
    padding: 16px; margin-bottom: 12px;
    transition: transform 0.1s;
}

/* ----- Status Badges ----- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 12px; border-radius: 100px;
    font-size: 12px; font-weight: 600;
    white-space: nowrap;
}
.badge-pending  { background: #FEF3C7; color: #92400E; }
.badge-partial  { background: #FEF3C7; color: #92400E; }
.badge-paid     { background: #D1FAE5; color: #065F46; }
.badge-overdue  { background: #FEE2E2; color: #991B1B; animation: pulse 2s infinite; }
.badge-unpaid   { background: #FEE2E2; color: #991B1B; }
.badge-ticket-submitted    { background: #FEF3C7; color: #92400E; }
.badge-ticket-acknowledged { background: #DBEAFE; color: #1E40AF; }
.badge-ticket-in_progress  { background: #EDE9FE; color: #5B21B6; }
.badge-ticket-completed    { background: #D1FAE5; color: #065F46; }
.badge-ticket-rejected     { background: #FEE2E2; color: #991B1B; }
.badge-priority-low    { background: #F3F4F6; color: #374151; }
.badge-priority-medium { background: #FEF3C7; color: #92400E; }
.badge-priority-high   { background: #FFEDD5; color: #C2410C; }
.badge-priority-urgent { background: #FEE2E2; color: #991B1B; animation: pulse 2s infinite; }
.badge-occupied    { background: #D1FAE5; color: #065F46; }
.badge-vacant      { background: #FEF3C7; color: #92400E; }
.badge-maintenance { background: #FEE2E2; color: #991B1B; }

/* ----- Form Inputs ----- */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; font-size: 14px; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 6px;
}
.form-input, .input-field {
    width: 100%; min-height: 48px; padding: 12px 16px;
    background: var(--input-bg); border: 2px solid var(--border);
    border-radius: 12px; font-size: 16px; color: var(--text-primary);
    outline: none; transition: border-color 0.15s;
    font-family: 'DM Sans', sans-serif;
}
.form-input:focus, .input-field:focus { border-color: var(--accent); }
.form-input::placeholder, .input-field::placeholder { color: var(--text-muted); }
.form-error { font-size: 13px; color: #DC2626; margin-top: 4px; }
.form-hint { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* PIN input boxes */
.pin-container { display: flex; gap: 12px; justify-content: center; }
.pin-box {
    width: 56px; height: 64px; text-align: center;
    font-size: 24px; font-weight: 700;
    background: var(--input-bg); color: var(--text-primary);
    border: 2px solid var(--border); border-radius: 12px;
    outline: none; transition: border-color 0.15s;
    -webkit-text-security: disc;
    font-family: 'DM Sans', sans-serif;
}
.pin-box:focus { border-color: var(--accent); }

/* Search */
.search-wrap { position: relative; margin-bottom: 16px; }
.search-wrap i, .search-wrap svg {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); pointer-events: none; z-index: 2; width: 20px; height: 20px;
}
.search-input {
    width: 100%; min-height: 48px; padding: 12px 16px 12px 44px;
    background: var(--input-bg); border: 2px solid var(--border);
    border-radius: 16px; font-size: 15px; color: var(--text-primary);
    outline: none; transition: border-color 0.15s;
    font-family: 'DM Sans', sans-serif;
}
.search-input:focus { border-color: var(--accent); }

/* ----- Filter Tabs ----- */
.filter-tabs {
    display: flex; gap: 8px; overflow-x: auto;
    padding-bottom: 4px; margin-bottom: 16px;
    -ms-overflow-style: none; scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
    flex-shrink: 0; padding: 8px 16px;
    border-radius: 100px; font-size: 13px; font-weight: 600;
    background: var(--surface); color: var(--text-tertiary); border: 1.5px solid var(--border);
    cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.filter-tab.active {
    background: var(--accent); color: white; border-color: var(--accent);
}

/* ----- Summary Cards ----- */
.summary-card {
    background: var(--surface); border-radius: 16px;
    padding: 16px; box-shadow: var(--shadow-sm);
    cursor: pointer; transition: transform 0.1s;
    text-decoration: none; display: block;
}
.summary-value {
    font-size: clamp(18px, 5vw, 28px); font-weight: 700; color: var(--text-primary);
    line-height: 1.2;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.summary-label {
    font-size: 13px; color: var(--text-tertiary); margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ----- Spinner ----- */
.spinner {
    width: 20px; height: 20px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}
.spinner-dark { border-color: rgba(0,0,0,0.1); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Toggle Switch ----- */
.toggle {
    position: relative; width: 48px; height: 28px;
    background: var(--border); border-radius: 14px;
    cursor: pointer; transition: background 0.2s; flex-shrink: 0;
    border: none;
}
.toggle.active { background: var(--accent); }
.toggle::after {
    content: ''; position: absolute;
    top: 2px; left: 2px; width: 24px; height: 24px;
    background: white; border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: transform 0.2s;
}
.toggle.active::after { transform: translateX(20px); }

/* ----- Color Swatches ----- */
.color-swatch {
    width: 40px; height: 40px; border-radius: 50%;
    cursor: pointer; border: 3px solid transparent;
    transition: border-color 0.15s, transform 0.1s;
}
.color-swatch.active { border-color: var(--text-primary); transform: scale(1.1); }

/* ----- Settings Groups (Accordion) ----- */
.settings-group {
    background: var(--surface); border-radius: 16px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px; overflow: hidden;
}
.settings-group summary {
    padding: 16px; font-weight: 600; font-size: 15px;
    cursor: pointer; list-style: none;
    display: flex; align-items: center; gap: 12px;
}
.settings-group summary::-webkit-details-marker { display: none; }
.settings-group summary::after {
    content: ''; margin-left: auto;
    width: 20px; height: 20px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat center;
    transition: transform 0.2s;
}
.settings-group[open] summary::after { transform: rotate(180deg); }
.settings-group .settings-body { padding: 0 16px 16px; }

/* ----- Section Header ----- */
.section-header {
    font-size: 13px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-muted);
    padding: 16px 0 8px;
}

/* ----- Skeleton Loading ----- */
.skeleton {
    background: linear-gradient(90deg, var(--skeleton-from) 25%, var(--skeleton-via) 50%, var(--skeleton-from) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ----- Animations ----- */
@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.animate-slideDown { animation: slideDown 0.3s ease-out; }
.animate-slideUp { animation: slideUp 0.3s ease-out; }
.animate-fadeIn { animation: fadeIn 0.2s ease-out; }
.animate-pulse { animation: pulse 2s infinite; }

/* ----- Utility ----- */
.text-accent { color: var(--accent); }
.bg-accent { background: var(--accent); }
.border-accent { border-color: var(--accent); }
.line-through { text-decoration: line-through; }
.truncate-2 {
    display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
}

/* ----- Toast Notification ----- */
.ps-toast {
    position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
    padding: 8px 20px; border-radius: 20px;
    font-size: 13px; font-weight: 500; color: white;
    z-index: 200; white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    animation: toastIn 0.25s ease-out;
    transition: opacity 0.25s, transform 0.25s;
}
.ps-toast.success { background: rgba(5,150,105,0.92); }
.ps-toast.error { background: rgba(220,38,38,0.92); }
.ps-toast.info { background: rgba(37,99,235,0.92); }
.ps-toast.warning { background: rgba(217,119,6,0.92); }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ----- Theme Transition ----- */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.2s ease, box-shadow 0.3s ease !important;
}
