/* ============================================================
   FASTIGHETSPORTAL — Shared custom CSS
   Tailwind handles layout/typography. This file covers
   PHP-generated HTML class names and shared components.
   ============================================================ */

/* ---- CSS Variables ---------------------------------------- */
:root {
    --primary: #004ac6;
    --primary-dark: #003ea8;
    --primary-light: #dbe1ff;
    --surface: #faf8ff;
    --surface-low: #f3f3fe;
    --surface-container: #ededf9;
    --surface-high: #e7e7f3;
    --on-surface: #191b23;
    --on-surface-muted: #434655;
    --outline: #737686;
    --outline-variant: #c3c6d7;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
    --radius: 0.5rem;
    --transition: .15s ease;
}

/* ---- Base reset for admin pages ---------------------------- */
*, *::before, *::after { box-sizing: border-box; }

/* ---- Material Symbols utility ------------------------------ */
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined', sans-serif;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    display: inline-block;
    width: 1em;
    height: 1em;
    overflow: hidden;
    flex-shrink: 0;
    vertical-align: middle;
    line-height: 1;
}
.icon-fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }

/* ---- Critical layout (before Tailwind CDN on public pages) --- */
.bento-grid { display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 768px) {
    .bento-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .bento-grid > .bento-span-2 { grid-column: span 2 / span 2; }
    #site-header .site-nav { display: flex; align-items: center; gap: 24px; }
}
@media (max-width: 767px) {
    #site-header .site-nav { display: none; }
}
.bento-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #fff;
    transition: all .3s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,.05);
}
.bento-card:hover { transform: translateY(-4px); box-shadow: 0 12px 24px -8px rgba(0,0,0,.10); }
.bento-grid .bento-media { height: 12rem; min-height: 12rem; }

/* ---- Site header dropdown ---------------------------------- */
.dropdown-group {
    display: inline-flex;
    position: relative;
    padding-bottom: 10px;
    margin-bottom: -10px;
}
.dropdown-trigger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.dropdown-group:hover .dropdown-panel,
.dropdown-group:focus-within .dropdown-panel { display: block; }
.dropdown-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #e1e2ed;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.10);
    min-width: 200px;
    z-index: 99;
    padding: 6px;
}
.dropdown-panel a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    font-size: 14px;
    font-weight: 500;
    color: #191b23;
    border-radius: 6px;
    text-decoration: none;
    transition: background .12s;
}
.dropdown-panel a:hover { background: #f3f3fe; color: #004ac6; }

.step-pill { background: linear-gradient(135deg, #004ac6 0%, #2563eb 100%); }
.glass-effect { background: rgba(255,255,255,.12); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.card-hover { transition: all .2s ease-in-out; }
.card-hover:hover { transform: translateY(-4px); box-shadow: 0 10px 15px -3px rgba(0,0,0,.1); }

/* ---- Status badges (getStatusBadge() output) --------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
}
.badge-new        { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.badge-ongoing    { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-completed  { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.badge-closed     { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.badge-available  { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.badge-occupied   { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.badge-maintenance,
.badge-unavailable { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }

/* ---- Alerts ----------------------------------------------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.alert-success  { background: #d1fae5; border: 1px solid #6ee7b7; color: #065f46; }
.alert-error    { background: #fee2e2; border: 1px solid #fca5a5; color: #b91c1c; }
.alert-info     { background: #dbeafe; border: 1px solid #93c5fd; color: #1e40af; }
.alert-warning  { background: #fef3c7; border: 1px solid #fde68a; color: #92400e; }

/* ---- Toast notifications ----------------------------------- */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: #1e293b;
    color: white;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toastIn .25s ease;
    min-width: 260px;
    max-width: 400px;
}
.toast-success { background: #065f46; }
.toast-error   { background: #b91c1c; }
.toast-icon { font-size: 18px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Floating contact button ------------------------------ */
.floating-contact {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: background var(--transition), transform var(--transition);
    z-index: 500;
}
.floating-contact:hover { background: var(--primary-dark); transform: scale(1.06); }
.floating-contact .material-symbols-outlined { font-size: 24px; }

/* ---- Contact modal ---------------------------------------- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.active { display: flex; }
.modal-content {
    background: white;
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--outline-variant);
}
.modal-header h2 { font-size: 18px; font-weight: 600; color: var(--on-surface); margin: 0; }
.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--outline);
    padding: 4px;
    line-height: 1;
    transition: color var(--transition);
}
.modal-close:hover { color: var(--on-surface); }
.modal-body { padding: 24px; }

/* ---- Admin component system ------------------------------- */
/* Admin pages keep these legacy classes for now */
.help-text {
    font-size: 12px;
    color: var(--outline);
    margin-top: 4px;
}

/* Checkbox group */
.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
}
.checkbox-group input[type="checkbox"] {
    margin-top: 3px;
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.checkbox-group label { font-size: 14px; color: var(--on-surface); line-height: 1.5; cursor: pointer; }

/* Image preview */
#imagePreview img { border-radius: var(--radius); border: 1px solid var(--outline-variant); }

/* ---- Activity log (tenant view) --------------------------- */
.activity-filter-btn {
    padding: 5px 14px;
    border: 1px solid var(--outline-variant);
    background: none;
    border-radius: 99px;
    cursor: pointer;
    font-size: 13px;
    color: var(--on-surface-muted);
    transition: all var(--transition);
}
.activity-filter-btn:hover,
.activity-filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ---- Tabs (admin settings) -------------------------------- */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--outline-variant);
    margin-bottom: 28px;
    overflow-x: auto;
}
.tabs a {
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    color: var(--on-surface-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: color var(--transition), border-color var(--transition);
}
.tabs a:hover { color: var(--primary); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- Tenant portal layout ---------------------------------- */
.tenant-page-banner {
    background: #fff;
    border-bottom: 1px solid #e1e2ed;
}
.tenant-page-banner-inner {
    max-width: 56rem;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 7.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.tenant-page-banner-inner--wide {
    max-width: 80rem;
}
@media (min-width: 640px) {
    .tenant-page-banner-inner { padding-left: 1.5rem; padding-right: 1.5rem; }
}
@media (min-width: 1024px) {
    .tenant-page-banner-inner { padding-left: 2rem; padding-right: 2rem; }
}
.tenant-page-banner-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.tenant-page-eyebrow {
    font-size: 0.875rem;
    color: #737686;
    margin: 0 0 0.25rem;
}
.tenant-page-title {
    font-size: 1.875rem;
    line-height: 2.25rem;
    font-weight: 700;
    color: #191b23;
    margin: 0;
}
.tenant-page-subtitle {
    margin: 0.25rem 0 0;
    font-size: 0.9375rem;
    line-height: 1.5rem;
    color: #434655;
}
.tenant-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: #004ac6;
    text-decoration: none;
    margin-bottom: 0.75rem;
}
.tenant-back-link:hover { text-decoration: underline; }
.tenant-page-content {
    max-width: 56rem;
    margin: 0 auto;
    padding: 2.5rem 1rem;
}
.tenant-page-content--wide {
    max-width: 80rem;
}
.tenant-page-content--narrow {
    max-width: 42rem;
}
@media (min-width: 640px) {
    .tenant-page-content { padding-left: 1.5rem; padding-right: 1.5rem; }
}
@media (min-width: 1024px) {
    .tenant-page-content { padding-left: 2rem; padding-right: 2rem; }
}
.tenant-card {
    background: #fff;
    border: 1px solid #e1e2ed;
    border-radius: 1rem;
    padding: 1.5rem;
}
.tenant-card--lg { padding: 2rem; }
.tenant-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #191b23;
    margin: 0 0 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.tenant-empty-state {
    text-align: center;
    padding: 3.5rem 1.5rem;
}
.tenant-unread-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #fef2f2;
    color: #dc2626;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.75rem;
    border: 1px solid #fee2e2;
    white-space: nowrap;
}

.thread-read-label {
    font-weight: 600;
    margin-left: 0.25rem;
}
.thread-read-label--unread {
    color: #004ac6;
}
.thread-read-label--read {
    color: #737686;
}
