@import url('shared.css');

/* ===================== MAIN CONTENT ===================== */
.main-content {
    flex: 1;
    width: 100%;
    margin: 0 auto;
    padding: clamp(24px, 4vh, 48px) clamp(12px, 2vw, 24px) clamp(12px, 2vh, 24px);
    display: flex; flex-direction: column;
    overflow: hidden;
}

/* ===================== EMPTY STATE ===================== */
.empty-state {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center;
    padding: clamp(16px, 3vh, 32px);
}

.empty-icon {
    width: clamp(64px, 10vh, 96px); height: clamp(64px, 10vh, 96px);
    border-radius: 50%;
    background: var(--gray-100);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: clamp(12px, 2vh, 24px);
}
.empty-icon svg {
    width: clamp(32px, 5vh, 48px); height: clamp(32px, 5vh, 48px);
    color: var(--gray-400);
}

.empty-state h2 {
    font-size: clamp(1rem, 2.2vh, 1.4rem);
    color: var(--secondary);
    margin-bottom: clamp(6px, 1vh, 10px);
}
.empty-state p {
    font-size: clamp(0.78rem, 1.5vh, 0.92rem);
    color: var(--text-light);
    max-width: 420px; line-height: 1.6;
}

/* ===================== TABLES VIEW ===================== */
.tables-view {
    flex: 1; display: flex; flex-direction: column;
    overflow: hidden;
}

/* Category Tabs */
.category-tabs {
    display: flex; gap: clamp(4px, 0.6vw, 8px);
    flex-shrink: 0;
    padding-bottom: clamp(10px, 1.5vh, 16px);
    margin-bottom: clamp(10px, 1.5vh, 16px);
    border-bottom: 1.5px solid var(--border);
    justify-content: center;
    flex-wrap: wrap;
}

.cat-tab {
    padding: clamp(8px, 1.2vh, 12px) clamp(14px, 2vw, 28px);
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text);
    font-size: clamp(0.72rem, 1.3vh, 0.9rem);
    font-weight: 700; font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    text-align: center;
}
.cat-tab:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.cat-tab.active {
    background: var(--primary); color: #fff;
    border-color: var(--primary);
    box-shadow: 0 3px 12px var(--primary-glow);
}

.cat-tab .tab-count {
    margin-left: 6px;
    font-size: clamp(0.65rem, 1.1vh, 0.78rem);
    opacity: 0.7;
}

/* Tables Grid */
.tables-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: clamp(8px, 1.2vw, 14px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: clamp(6px, 1vh, 10px) 8px;
    scrollbar-width: thin;
    align-content: start;
}
.tables-grid::-webkit-scrollbar { width: 4px; }
.tables-grid::-webkit-scrollbar-track { background: transparent; }
.tables-grid::-webkit-scrollbar-thumb { background: var(--gray-300, #dee2e6); border-radius: 4px; }

/* ===================== TABLE CARD ===================== */
.table-card {
    border-radius: 18px;
    display: flex; flex-direction: column;
    align-items: stretch;
    transition: all 0.3s cubic-bezier(.4,0,.2,1);
    position: relative;
    user-select: none;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.table-card:hover {
    transform: translateY(-5px);
}

/* Badge (category) */
.table-card .card-badge {
    text-align: center;
    padding: clamp(3px, 0.5vh, 6px) 6px;
    font-size: clamp(0.48rem, 0.75vw, 0.62rem);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    flex-shrink: 0;
}

/* Body (number + label) */
.table-card .card-body {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 1px;
    padding: clamp(8px, 1.5vw, 16px) 6px;
}

.table-card .card-number {
    font-size: clamp(1.4rem, 3.5vw, 2.4rem);
    font-weight: 900;
    line-height: 1;
    letter-spacing: -1px;
}

.table-card .card-label {
    font-size: clamp(0.4rem, 0.6vw, 0.52rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 3px;
    opacity: 0.5;
}
.table-card .card-opened-by {
    font-size: clamp(0.5rem, 0.8vw, 0.62rem);
    font-weight: 600;
    color: var(--primary);
    opacity: 0.85;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}

/* Last order time */
.card-last-order {
    font-size: clamp(0.45rem, 0.7vw, 0.58rem);
    font-weight: 600;
    color: var(--success);
    text-align: center;
    padding: 2px 6px;
    margin: 0 6px;
    border-radius: 6px;
    background: rgba(39,174,96,0.08);
}
.card-last-order.stale {
    color: #dc2626;
    background: rgba(220,38,38,0.08);
    animation: stalePulse 2s ease-in-out infinite;
}
.stale-warning {
    border-color: rgba(220,38,38,0.5) !important;
    box-shadow: 0 0 0 2px rgba(220,38,38,0.12), 0 4px 12px rgba(220,38,38,0.1) !important;
}

@keyframes stalePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Footer (status) */
.table-card .card-footer {
    display: flex; align-items: center; justify-content: center;
    gap: 4px;
    padding: clamp(3px, 0.5vh, 7px) 6px;
    font-size: clamp(0.5rem, 0.7vw, 0.65rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.table-card .card-footer svg {
    flex-shrink: 0; opacity: 0.8;
    width: clamp(10px, 1.2vw, 14px); height: clamp(10px, 1.2vw, 14px);
}

/* ── Empty Table ── */
.table-card.status-empty {
    background: linear-gradient(145deg, #ffffff 0%, #ecfdf5 50%, #d1fae5 100%);
    border: 1.5px solid rgba(39,174,96,0.25);
    cursor: pointer;
    box-shadow:
        0 1px 3px rgba(39,174,96,0.06),
        0 4px 12px rgba(39,174,96,0.04),
        inset 0 1px 0 rgba(255,255,255,0.8);
}
.table-card.status-empty .card-badge {
    background: linear-gradient(135deg, rgba(39,174,96,0.1), rgba(39,174,96,0.05));
    color: #16a34a;
}
.table-card.status-empty .card-number { color: #15803d; }
.table-card.status-empty .card-label { color: #16a34a; }
.table-card.status-empty .card-footer {
    background: linear-gradient(0deg, rgba(39,174,96,0.06), transparent);
    color: #16a34a;
}
.table-card.status-empty:hover {
    border-color: rgba(39,174,96,0.5);
    box-shadow:
        0 4px 12px rgba(39,174,96,0.1),
        0 12px 32px rgba(39,174,96,0.08),
        inset 0 1px 0 rgba(255,255,255,0.8);
}

/* ── Occupied Table ── */
.table-card.status-occupied {
    background: linear-gradient(145deg, #ffffff 0%, #fef2f2 50%, #fee2e2 100%);
    border: 1.5px solid rgba(231,76,60,0.25);
    cursor: pointer;
    box-shadow:
        0 1px 3px rgba(231,76,60,0.06),
        0 4px 12px rgba(231,76,60,0.04),
        inset 0 1px 0 rgba(255,255,255,0.8);
}
.table-card.status-occupied .card-badge {
    background: linear-gradient(135deg, rgba(231,76,60,0.12), rgba(231,76,60,0.05));
    color: var(--primary-dark);
}
.table-card.status-occupied .card-number { color: var(--primary); }
.table-card.status-occupied .card-label { color: var(--primary); }
.table-card.status-occupied .card-footer {
    background: linear-gradient(0deg, rgba(231,76,60,0.06), transparent);
    color: var(--primary-dark);
}
.table-card.status-occupied:hover {
    border-color: rgba(231,76,60,0.4);
    box-shadow:
        0 4px 12px rgba(231,76,60,0.1),
        0 12px 32px rgba(231,76,60,0.06),
        inset 0 1px 0 rgba(255,255,255,0.8);
}

/* Live indicator for occupied */
.table-card.status-occupied .card-footer svg {
    animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 0.3; }
}

/* ── Reserved Table ── */
.table-card.status-reserved {
    background: linear-gradient(145deg, #ffffff 0%, #f5f3ff 50%, #ede9fe 100%);
    border: 1.5px solid rgba(139,92,246,0.3);
    cursor: pointer;
    box-shadow:
        0 1px 3px rgba(139,92,246,0.06),
        0 4px 12px rgba(139,92,246,0.04),
        inset 0 1px 0 rgba(255,255,255,0.8);
}
.table-card.status-reserved .card-badge {
    background: linear-gradient(135deg, rgba(139,92,246,0.12), rgba(139,92,246,0.05));
    color: #7c3aed;
}
.table-card.status-reserved .card-number { color: #7c3aed; }
.table-card.status-reserved .card-label { color: #8b5cf6; }
.table-card.status-reserved .card-footer {
    background: linear-gradient(0deg, rgba(139,92,246,0.06), transparent);
    color: #7c3aed;
}
.table-card.status-reserved:hover {
    border-color: rgba(139,92,246,0.5);
    box-shadow:
        0 4px 12px rgba(139,92,246,0.1),
        0 12px 32px rgba(139,92,246,0.08),
        inset 0 1px 0 rgba(255,255,255,0.8);
}
.table-card.status-reserved .card-footer svg {
    animation: reservePulse 3s ease-in-out infinite;
}
@keyframes reservePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@media (max-width: 768px) {
    .main-content { overflow: auto; }
    .tables-view { overflow: visible; flex: none; }
    .tables-grid { overflow: visible; flex: none; }
    .table-card .card-badge { padding: 6px 6px; font-size: 0.58rem; }
    .table-card .card-body { padding: 20px 6px; }
    .table-card .card-number { font-size: 2rem; }
    .table-card .card-label { font-size: 0.5rem; }
    .table-card .card-footer { padding: 7px 6px; font-size: 0.65rem; }
    .table-card .card-footer svg { width: 13px; height: 13px; }
}

/* ===================== CUSTOMERS TAB STYLE ===================== */
.cat-tab-customers {
    border-color: #0d9488 !important;
    color: #0d9488;
    background: #f0fdfa;
}
.cat-tab-customers:hover {
    border-color: #0d9488 !important;
    color: #0d9488 !important;
    background: #ccfbf1 !important;
}
.cat-tab-customers.active {
    background: #0d9488 !important;
    color: #fff !important;
    border-color: #0d9488 !important;
    box-shadow: 0 3px 12px rgba(13,148,136,0.3) !important;
}
.cat-tab-customers.active svg { stroke: #fff; }
.cat-tab-customers svg { stroke: #0d9488; }

/* ===================== CUSTOMER CARD ===================== */
.customer-card-index {
    border-radius: 18px;
    display: flex; flex-direction: column;
    align-items: stretch;
    transition: all 0.3s cubic-bezier(.4,0,.2,1);
    position: relative;
    user-select: none;
    overflow: hidden;
    backdrop-filter: blur(10px);
}
.customer-card-index:hover {
    transform: translateY(-5px);
}

.customer-card-index .cust-avatar-area {
    display: flex; align-items: center; justify-content: center;
    padding: clamp(12px, 2vw, 20px) 6px clamp(4px, 0.5vh, 6px);
}
.customer-card-index .cust-avatar-circle {
    width: clamp(34px, 5vw, 48px); height: clamp(34px, 5vw, 48px);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: clamp(0.8rem, 1.8vw, 1.2rem);
    font-weight: 900;
    letter-spacing: -0.5px;
}
.customer-card-index .cust-name {
    text-align: center;
    font-size: clamp(0.6rem, 1vw, 0.75rem);
    font-weight: 700;
    padding: 0 6px clamp(4px, 0.5vh, 8px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.customer-card-index .card-footer {
    display: flex; align-items: center; justify-content: center;
    gap: 4px;
    padding: clamp(3px, 0.5vh, 7px) 6px;
    font-size: clamp(0.5rem, 0.7vw, 0.65rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.customer-card-index .card-footer svg {
    flex-shrink: 0; opacity: 0.8;
    width: clamp(10px, 1.2vw, 14px); height: clamp(10px, 1.2vw, 14px);
}

/* Empty customer */
.customer-card-index.status-empty {
    background: linear-gradient(145deg, #ffffff 0%, #ecfdf5 50%, #d1fae5 100%);
    border: 1.5px solid rgba(39,174,96,0.25);
    cursor: pointer;
    box-shadow:
        0 1px 3px rgba(39,174,96,0.06),
        0 4px 12px rgba(39,174,96,0.04),
        inset 0 1px 0 rgba(255,255,255,0.8);
}
.customer-card-index.status-empty .cust-avatar-circle {
    background: rgba(39,174,96,0.12); color: #15803d;
}
.customer-card-index.status-empty .cust-name { color: #15803d; }
.customer-card-index.status-empty .card-footer {
    background: linear-gradient(0deg, rgba(39,174,96,0.06), transparent);
    color: #16a34a;
}
.customer-card-index.status-empty:hover {
    border-color: rgba(39,174,96,0.5);
    box-shadow:
        0 4px 12px rgba(39,174,96,0.1),
        0 12px 32px rgba(39,174,96,0.08),
        inset 0 1px 0 rgba(255,255,255,0.8);
}

/* Occupied customer */
.customer-card-index.status-occupied {
    background: linear-gradient(145deg, #ffffff 0%, #fef2f2 50%, #fee2e2 100%);
    border: 1.5px solid rgba(231,76,60,0.25);
    cursor: pointer;
    box-shadow:
        0 1px 3px rgba(231,76,60,0.06),
        0 4px 12px rgba(231,76,60,0.04),
        inset 0 1px 0 rgba(255,255,255,0.8);
}
.customer-card-index.status-occupied .cust-avatar-circle {
    background: rgba(231,76,60,0.12); color: var(--primary);
}
.customer-card-index.status-occupied .cust-name { color: var(--primary); }
.customer-card-index.status-occupied .card-footer {
    background: linear-gradient(0deg, rgba(231,76,60,0.06), transparent);
    color: var(--primary-dark);
}
.customer-card-index.status-occupied .card-footer svg {
    animation: livePulse 2s ease-in-out infinite;
}
.customer-card-index.status-occupied:hover {
    border-color: rgba(231,76,60,0.4);
    box-shadow:
        0 4px 12px rgba(231,76,60,0.1),
        0 12px 32px rgba(231,76,60,0.06),
        inset 0 1px 0 rgba(255,255,255,0.8);
}

/* ===================== TOOLBAR ===================== */
.tables-toolbar {
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.2vh, 12px);
    flex-shrink: 0;
    padding-bottom: clamp(10px, 1.5vh, 16px);
    margin-bottom: clamp(10px, 1.5vh, 16px);
    border-bottom: 1.5px solid var(--border);
}

.tables-toolbar .category-tabs {
    padding-bottom: 0;
    margin-bottom: 0;
    border-bottom: none;
    justify-content: center;
}

.toolbar-actions {
    justify-content: center;
}

.toolbar-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: center;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: clamp(8px, 1.2vh, 11px) clamp(12px, 1.5vw, 18px);
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text);
    font-size: clamp(0.68rem, 1.2vh, 0.82rem);
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.toolbar-btn svg { flex-shrink: 0; color: var(--text-light); transition: color 0.2s ease; }
.toolbar-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: #eff6ff;
}
.toolbar-btn:hover svg { color: #3b82f6; }

.toolbar-btn.active {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
    box-shadow: 0 3px 12px rgba(59,130,246,0.3);
}
.toolbar-btn.active svg { color: #fff; }

.toolbar-btn-reserve:hover {
    border-color: #8b5cf6;
    color: #8b5cf6;
    background: #f5f3ff;
}
.toolbar-btn-reserve:hover svg { color: #8b5cf6; }
.toolbar-btn-reserve.active {
    background: #8b5cf6;
    border-color: #8b5cf6;
    box-shadow: 0 3px 12px rgba(139,92,246,0.3);
}

/* ===================== SELECTION BANNER ===================== */
.selection-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border: 1.5px solid rgba(59,130,246,0.25);
    border-radius: 12px;
    margin-bottom: clamp(8px, 1.2vh, 14px);
    flex-shrink: 0;
    animation: bannerSlide 0.25s ease;
}
@keyframes bannerSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.selection-banner-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.selection-step {
    display: flex;
    align-items: center;
    gap: 8px;
}
.selection-step.done .selection-step-num {
    background: #22c55e;
}

.selection-step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #3b82f6;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.selection-step-text {
    font-size: 0.76rem;
    font-weight: 600;
    color: #1e40af;
}

.selection-selected {
    display: flex;
    align-items: center;
    gap: 8px;
}
.selection-selected svg {
    color: #3b82f6;
    flex-shrink: 0;
}

.selection-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: #3b82f6;
    color: #fff;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
}

.selection-cancel-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1.5px solid rgba(231,76,60,0.3);
    border-radius: 8px;
    background: #fff;
    color: var(--danger);
    font-size: 0.72rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.selection-cancel-btn:hover {
    background: #fef2f2;
    border-color: var(--danger);
}

/* Selection mode card effects */
body.selection-active .table-card,
body.selection-active .customer-card-index {
    cursor: pointer !important;
    transition: all 0.15s ease;
}

body.selection-active .table-card:hover,
body.selection-active .customer-card-index:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(59,130,246,0.15) !important;
    border-color: #3b82f6 !important;
}

.table-card.selection-source,
.customer-card-index.selection-source {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2), 0 6px 20px rgba(59,130,246,0.15) !important;
    transform: scale(1.03);
}
.table-card.selection-source::after,
.customer-card-index.selection-source::after {
    content: '✓';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===================== CONFIRM DIALOG ===================== */
.confirm-dialog-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}
.confirm-dialog-overlay.active {
    opacity: 1;
    visibility: visible;
}

.confirm-dialog {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 28px 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 16px 48px rgba(0,0,0,0.2);
    transform: scale(0.9);
    transition: transform 0.25s ease;
}
.confirm-dialog-overlay.active .confirm-dialog {
    transform: scale(1);
}

.confirm-dialog-icon {
    width: 56px; height: 56px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
}

.confirm-dialog h3 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
}
.confirm-dialog p {
    font-size: 0.82rem;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 22px;
    white-space: pre-line;
}

.confirm-dialog-actions {
    display: flex;
    gap: 10px;
}

.confirm-dialog-btn {
    flex: 1;
    padding: 11px 20px;
    border-radius: 10px;
    border: none;
    font-size: 0.82rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}
.confirm-dialog-cancel {
    background: var(--gray-100);
    color: var(--text);
}
.confirm-dialog-cancel:hover {
    background: var(--gray-200);
}
.confirm-dialog-ok {
    color: #fff;
}
.confirm-dialog-ok:hover {
    transform: translateY(-1px);
}
