/* ============================================================
   Tavooli — Frontdesk CSS
   Dark theme optimized for tablet use during restaurant service
   ============================================================ */

:root {
    --fd-bg: #0f1729;
    --fd-bg-secondary: #1a2332;
    --fd-bg-tertiary: #243044;
    --fd-border: #2d3f57;
    --fd-text: #e2e8f0;
    --fd-text-muted: #8a9bb5;
    --fd-text-dim: #5a6b82;
    --fd-accent: #3b82f6;
    --fd-accent-hover: #2563eb;

    /* Status colors */
    --fd-pending: #eab308;
    --fd-pending-bg: rgba(234, 179, 8, 0.15);
    --fd-confirmed: #3b82f6;
    --fd-confirmed-bg: rgba(59, 130, 246, 0.15);
    --fd-seated: #22c55e;
    --fd-seated-bg: rgba(34, 197, 94, 0.15);
    --fd-completed: #6b7280;
    --fd-completed-bg: rgba(107, 114, 128, 0.15);
    --fd-cancelled: #ef4444;
    --fd-cancelled-bg: rgba(239, 68, 68, 0.15);
    --fd-noshow: #ef4444;
    --fd-noshow-bg: rgba(239, 68, 68, 0.15);

    /* Floor plan table colors */
    --fp-free: #22c55e;
    --fp-reserved: #3b82f6;
    --fp-occupied: #ef4444;
    --fp-arriving: #eab308;
    --fp-inactive: #4b5563;

    /* Spacing */
    --fd-gap: 16px;
    --fd-radius: 8px;
    --fd-radius-sm: 4px;
}

/* ---- Reset & base ---- */
.fd-page {
    margin: 0;
    padding: 0;
    background: var(--fd-bg);
    color: var(--fd-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
}

.fd-page * { box-sizing: border-box; }

/* ---- Top nav bar ---- */
.fd-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--fd-bg-secondary);
    border-bottom: 1px solid var(--fd-border);
    padding: 0 20px;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.fd-topbar-brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--fd-accent);
    text-decoration: none;
}

.fd-topbar-nav {
    display: flex;
    gap: 4px;
}

.fd-topbar-nav a {
    color: var(--fd-text-muted);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--fd-radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.fd-topbar-nav a:hover,
.fd-topbar-nav a.active {
    background: var(--fd-bg-tertiary);
    color: var(--fd-text);
}

.fd-topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fd-topbar-clock {
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--fd-text);
}

/* ---- Split panel layout ---- */
.fd-split {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.fd-panel-left {
    flex: 0 0 60%;
    overflow-y: auto;
    border-right: 1px solid var(--fd-border);
    padding: var(--fd-gap);
}

.fd-panel-right {
    flex: 0 0 40%;
    overflow-y: auto;
    padding: var(--fd-gap);
    display: flex;
    flex-direction: column;
    gap: var(--fd-gap);
}

/* ---- Section cards ---- */
.fd-card {
    background: var(--fd-bg-secondary);
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius);
    padding: 16px;
}

.fd-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.fd-card-title {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fd-text-muted);
    margin: 0;
}

/* ---- Timeline ---- */
.fd-timeline {
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
}

.fd-timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.fd-timeline-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.fd-timeline-date {
    font-size: 14px;
    color: var(--fd-text-muted);
}

.fd-timeline-container {
    position: relative;
    min-height: 200px;
}

.fd-timeline-hours {
    display: flex;
    border-bottom: 1px solid var(--fd-border);
    padding-bottom: 4px;
    margin-bottom: 8px;
    user-select: none;
}

.fd-timeline-hour {
    flex: 0 0 120px;
    font-size: 12px;
    font-weight: 500;
    color: var(--fd-text-dim);
    border-left: 1px solid var(--fd-border);
    padding-left: 6px;
    position: relative;
}

.fd-timeline-hour.current {
    color: var(--fd-accent);
}

.fd-timeline-now-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--fd-accent);
    z-index: 5;
    pointer-events: none;
}

.fd-timeline-now-dot {
    position: absolute;
    top: -4px;
    left: -4px;
    width: 10px;
    height: 10px;
    background: var(--fd-accent);
    border-radius: 50%;
}

.fd-timeline-rows {
    position: relative;
}

.fd-timeline-row {
    position: relative;
    height: 52px;
    margin-bottom: 4px;
}

.fd-timeline-row-label {
    position: absolute;
    left: 0;
    top: 0;
    width: 80px;
    height: 100%;
    display: flex;
    align-items: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--fd-text-muted);
    z-index: 2;
}

/* ---- Booking blocks on timeline ---- */
.fd-booking-block {
    position: absolute;
    top: 4px;
    height: 44px;
    border-radius: var(--fd-radius-sm);
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    transition: transform 0.1s, box-shadow 0.1s;
    border: 1px solid transparent;
    z-index: 3;
    min-width: 40px;
}

.fd-booking-block:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 4;
}

.fd-booking-block.expanded {
    z-index: 10;
    height: auto;
    min-height: 44px;
}

.fd-booking-block .block-name {
    font-weight: 600;
    line-height: 1.2;
}

.fd-booking-block .block-meta {
    font-size: 11px;
    opacity: 0.8;
    line-height: 1.2;
}

/* Status variants */
.fd-booking-block.status-pending {
    background: var(--fd-pending-bg);
    border-color: var(--fd-pending);
    color: var(--fd-pending);
}

.fd-booking-block.status-confirmed {
    background: var(--fd-confirmed-bg);
    border-color: var(--fd-confirmed);
    color: var(--fd-confirmed);
}

.fd-booking-block.status-seated {
    background: var(--fd-seated-bg);
    border-color: var(--fd-seated);
    color: var(--fd-seated);
}

.fd-booking-block.status-completed {
    background: var(--fd-completed-bg);
    border-color: var(--fd-completed);
    color: var(--fd-completed);
}

.fd-booking-block.status-cancelled {
    background: var(--fd-cancelled-bg);
    border-color: var(--fd-cancelled);
    color: var(--fd-cancelled);
}

.fd-booking-block.status-no_show {
    background: var(--fd-noshow-bg);
    border-color: var(--fd-noshow);
    color: var(--fd-noshow);
}

/* ---- Booking detail popup ---- */
.fd-booking-detail {
    display: none;
    position: fixed;
    background: var(--fd-bg-secondary);
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius);
    padding: 16px;
    min-width: 300px;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 200;
}

.fd-booking-detail.visible {
    display: block;
}

.fd-booking-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.fd-booking-detail-header h3 {
    margin: 0;
    font-size: 16px;
}

.fd-booking-detail-close {
    background: none;
    border: none;
    color: var(--fd-text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
    line-height: 1;
}

.fd-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
}

.fd-detail-label {
    color: var(--fd-text-muted);
}

.fd-detail-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* ---- Status badges ---- */
.fd-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 10px;
}

.fd-badge-pending   { background: var(--fd-pending-bg); color: var(--fd-pending); }
.fd-badge-confirmed { background: var(--fd-confirmed-bg); color: var(--fd-confirmed); }
.fd-badge-seated    { background: var(--fd-seated-bg); color: var(--fd-seated); }
.fd-badge-completed { background: var(--fd-completed-bg); color: var(--fd-completed); }
.fd-badge-cancelled { background: var(--fd-cancelled-bg); color: var(--fd-cancelled); }
.fd-badge-no_show   { background: var(--fd-noshow-bg); color: var(--fd-noshow); }

/* ---- Buttons ---- */
.fd-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--fd-radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    color: #fff;
    min-height: 44px;
    /* Large touch targets for tablet use */
}

.fd-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.fd-btn-primary {
    background: var(--fd-accent);
}
.fd-btn-primary:hover:not(:disabled) { background: var(--fd-accent-hover); }

.fd-btn-success {
    background: var(--fd-seated);
}
.fd-btn-success:hover:not(:disabled) { background: #16a34a; }

.fd-btn-warning {
    background: var(--fd-pending);
    color: #000;
}
.fd-btn-warning:hover:not(:disabled) { background: #ca8a04; }

.fd-btn-danger {
    background: var(--fd-cancelled);
}
.fd-btn-danger:hover:not(:disabled) { background: #dc2626; }

.fd-btn-ghost {
    background: transparent;
    color: var(--fd-text-muted);
    border: 1px solid var(--fd-border);
}
.fd-btn-ghost:hover:not(:disabled) {
    background: var(--fd-bg-tertiary);
    color: var(--fd-text);
}

.fd-btn-sm {
    padding: 6px 10px;
    font-size: 12px;
    min-height: 32px;
}

.fd-btn-lg {
    padding: 14px 24px;
    font-size: 16px;
    min-height: 52px;
}

.fd-btn-walkin {
    width: 100%;
    background: var(--fd-seated);
    font-size: 16px;
    font-weight: 600;
    min-height: 52px;
}
.fd-btn-walkin:hover { background: #16a34a; }

/* ---- Quick search ---- */
.fd-search {
    position: relative;
}

.fd-search input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    background: var(--fd-bg-tertiary);
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius-sm);
    color: var(--fd-text);
    font-size: 14px;
    min-height: 44px;
    outline: none;
}

.fd-search input:focus {
    border-color: var(--fd-accent);
}

.fd-search input::placeholder {
    color: var(--fd-text-dim);
}

.fd-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--fd-text-dim);
    font-size: 16px;
    pointer-events: none;
}

.fd-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--fd-bg-secondary);
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius-sm);
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 50;
    display: none;
}

.fd-search-results.visible {
    display: block;
}

.fd-search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid var(--fd-border);
}

.fd-search-result-item:last-child { border-bottom: none; }

.fd-search-result-item:hover {
    background: var(--fd-bg-tertiary);
}

/* ---- Table status mini-grid ---- */
.fd-table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 8px;
}

.fd-table-mini {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    border-radius: var(--fd-radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s;
    min-height: 56px;
}

.fd-table-mini:hover {
    border-color: var(--fd-text-dim);
}

.fd-table-mini .table-name {
    font-size: 12px;
    font-weight: 600;
}

.fd-table-mini .table-cap {
    font-size: 10px;
    opacity: 0.7;
}

.fd-table-mini.status-free      { background: rgba(34, 197, 94, 0.2); color: var(--fp-free); }
.fd-table-mini.status-reserved  { background: rgba(59, 130, 246, 0.2); color: var(--fp-reserved); }
.fd-table-mini.status-occupied  { background: rgba(239, 68, 68, 0.2); color: var(--fp-occupied); }

/* ---- Upcoming arrivals list ---- */
.fd-arrival-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fd-arrival-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--fd-border);
    font-size: 13px;
}

.fd-arrival-item:last-child { border-bottom: none; }

.fd-arrival-time {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 50px;
}

.fd-arrival-name {
    flex: 1;
    margin: 0 8px;
}

.fd-arrival-party {
    color: var(--fd-text-muted);
    font-size: 12px;
}

/* ---- Stats row ---- */
.fd-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: var(--fd-gap);
}

.fd-stat {
    text-align: center;
    padding: 12px 8px;
    background: var(--fd-bg-secondary);
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius);
}

.fd-stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}

.fd-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fd-text-muted);
    margin-top: 2px;
}

/* ---- Walk-in modal ---- */
.fd-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 500;
    align-items: center;
    justify-content: center;
}

.fd-modal-overlay.visible {
    display: flex;
}

.fd-modal {
    background: var(--fd-bg-secondary);
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius);
    padding: 24px;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

.fd-modal h2 {
    margin: 0 0 16px 0;
    font-size: 20px;
}

.fd-form-group {
    margin-bottom: 16px;
}

.fd-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--fd-text-muted);
    margin-bottom: 4px;
}

.fd-form-group input,
.fd-form-group select,
.fd-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--fd-bg-tertiary);
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius-sm);
    color: var(--fd-text);
    font-size: 14px;
    min-height: 44px;
    outline: none;
}

.fd-form-group input:focus,
.fd-form-group select:focus,
.fd-form-group textarea:focus {
    border-color: var(--fd-accent);
}

.fd-form-group textarea {
    min-height: 60px;
    resize: vertical;
}

.fd-party-size-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.fd-party-btn {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--fd-border);
    border-radius: var(--fd-radius);
    background: var(--fd-bg-tertiary);
    color: var(--fd-text);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.fd-party-btn:hover {
    border-color: var(--fd-accent);
}

.fd-party-btn.selected {
    border-color: var(--fd-accent);
    background: rgba(59, 130, 246, 0.2);
    color: var(--fd-accent);
}

/* Available tables in walk-in form */
.fd-walkin-tables {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.fd-walkin-table {
    padding: 12px 8px;
    text-align: center;
    border: 2px solid var(--fd-border);
    border-radius: var(--fd-radius);
    background: var(--fd-bg-tertiary);
    cursor: pointer;
    transition: border-color 0.15s;
}

.fd-walkin-table:hover {
    border-color: var(--fd-seated);
}

.fd-walkin-table.selected {
    border-color: var(--fd-seated);
    background: rgba(34, 197, 94, 0.15);
}

.fd-walkin-table .t-name {
    font-weight: 600;
    font-size: 14px;
}

.fd-walkin-table .t-cap {
    font-size: 11px;
    color: var(--fd-text-muted);
}

/* ---- Floor plan page ---- */
.fd-floorplan-container {
    height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
}

.fd-floorplan-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px var(--fd-gap);
    background: var(--fd-bg-secondary);
    border-bottom: 1px solid var(--fd-border);
    flex-shrink: 0;
    gap: 12px;
}

.fd-floorplan-toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fd-floorplan-canvas-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--fd-bg);
}

.fd-floorplan-canvas-wrap svg {
    width: 100%;
    height: 100%;
}

/* Floor plan legend */
.fd-legend {
    display: flex;
    gap: 16px;
    font-size: 12px;
    align-items: center;
}

.fd-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fd-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.fd-legend-dot.c-free      { background: var(--fp-free); }
.fd-legend-dot.c-reserved  { background: var(--fp-reserved); }
.fd-legend-dot.c-occupied  { background: var(--fp-occupied); }
.fd-legend-dot.c-arriving  { background: var(--fp-arriving); }
.fd-legend-dot.c-inactive  { background: var(--fp-inactive); }

/* Floor plan SVG table styles */
.fp-table {
    cursor: pointer;
    transition: opacity 0.15s;
}

.fp-table:hover {
    opacity: 0.85;
}

.fp-table-shape {
    stroke-width: 2;
    stroke: rgba(255,255,255,0.2);
}

.fp-table.s-free .fp-table-shape      { fill: var(--fp-free); }
.fp-table.s-reserved .fp-table-shape   { fill: var(--fp-reserved); }
.fp-table.s-occupied .fp-table-shape   { fill: var(--fp-occupied); }
.fp-table.s-arriving .fp-table-shape   { fill: var(--fp-arriving); }
.fp-table.s-inactive .fp-table-shape   { fill: var(--fp-inactive); }

.fp-table-label {
    fill: #fff;
    font-size: 12px;
    font-weight: 600;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.fp-table-cap {
    fill: rgba(255,255,255,0.7);
    font-size: 10px;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.fp-table.dragging {
    opacity: 0.7;
}

/* Floor plan tooltip */
.fd-fp-tooltip {
    display: none;
    position: fixed;
    background: var(--fd-bg-secondary);
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    z-index: 300;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    pointer-events: none;
    max-width: 240px;
}

.fd-fp-tooltip.visible {
    display: block;
}

.fd-fp-tooltip strong {
    display: block;
    margin-bottom: 2px;
}

/* ---- Zoom controls ---- */
.fd-zoom-controls {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 50;
}

.fd-zoom-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--fd-bg-secondary);
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius-sm);
    color: var(--fd-text);
    font-size: 18px;
    cursor: pointer;
}

.fd-zoom-btn:hover {
    background: var(--fd-bg-tertiary);
}

/* ---- Responsive: stack on mobile ---- */
@media (max-width: 900px) {
    .fd-split {
        flex-direction: column;
        height: auto;
    }
    .fd-panel-left,
    .fd-panel-right {
        flex: none;
        width: 100%;
        border-right: none;
    }
    .fd-panel-left {
        border-bottom: 1px solid var(--fd-border);
    }
    .fd-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .fd-stats {
        grid-template-columns: 1fr 1fr;
    }
    .fd-topbar-nav {
        display: none;
    }
}

/* ---- Utility / misc ---- */
.fd-empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--fd-text-dim);
    font-size: 14px;
}

.fd-loading {
    text-align: center;
    padding: 24px;
    color: var(--fd-text-dim);
}

.fd-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--fd-bg-secondary);
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius);
    padding: 12px 20px;
    font-size: 14px;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
}

.fd-toast.visible {
    transform: translateY(0);
    opacity: 1;
}

.fd-toast.toast-success { border-left: 4px solid var(--fd-seated); }
.fd-toast.toast-error   { border-left: 4px solid var(--fd-cancelled); }
.fd-toast.toast-info    { border-left: 4px solid var(--fd-accent); }

/* Scrollbar styling */
.fd-page ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.fd-page ::-webkit-scrollbar-track {
    background: transparent;
}
.fd-page ::-webkit-scrollbar-thumb {
    background: var(--fd-border);
    border-radius: 3px;
}
