/* =============================================
   DESIGN TOKENS
   ============================================= */
:root {
    --primary: #667eea;
    --primary-dark: #5a6fd6;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-gradient-hover: linear-gradient(135deg, #764ba2 0%, #667eea 100%);

    --danger: #e74c3c;
    --danger-hover: #c0392b;
    --success: #27ae60;

    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);

    --text-primary: #1a1a2e;
    --text-secondary: #4a5568;
    --text-muted: #9ca3af;

    --bg-body: #f0f2f5;
    --bg-hover: rgba(102, 126, 234, 0.06);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --transition: 0.2s ease;
}

/* =============================================
   RESET & BASE
   ============================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(45deg, #fdfbfb, #ebedee, #f0f2f5);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    height: 100vh;
    overflow: hidden;
    color: var(--text-primary);
    line-height: 1.5;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: 1.3;
}

/* =============================================
   APP LAYOUT (Sidebar + Main)
   ============================================= */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 300px;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow: hidden;
}

.main-content {
    flex: 1;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* =============================================
   GLASS PANEL
   ============================================= */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--glass-border);
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.controls-section {
    margin-bottom: 20px;
}

.section-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.members-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

.sidebar-footer {
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.fw-bold {
    font-weight: 700;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    padding: 10px 18px;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
    outline: none;
    text-decoration: none;
    line-height: 1.4;
}

.btn:active {
    transform: scale(0.97);
}

.btn-block {
    width: 100%;
    margin-bottom: 10px;
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.8rem;
}

/* Primary */
.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.35);
}

.btn-primary:hover {
    background: var(--primary-gradient-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.45);
}

/* Manage (visible on glass panel) */
.btn-manage {
    background: rgba(30, 30, 60, 0.08);
    color: var(--text-primary);
    border: 1.5px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.btn-manage:hover {
    background: rgba(30, 30, 60, 0.14);
    border-color: rgba(0, 0, 0, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Secondary */
.btn-secondary {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Danger */
.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 3px 12px rgba(231, 76, 60, 0.3);
}

.btn-danger:hover {
    background: var(--danger-hover);
    transform: translateY(-1px);
    box-shadow: 0 5px 16px rgba(231, 76, 60, 0.4);
}

/* Outline icon buttons (for table actions) */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: var(--radius-sm);
    border: 1px solid;
    background: transparent;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--transition);
}

.btn-icon-edit {
    color: var(--primary);
    border-color: rgba(102, 126, 234, 0.3);
}

.btn-icon-edit:hover {
    background: rgba(102, 126, 234, 0.1);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.btn-icon-delete {
    color: var(--danger);
    border-color: rgba(231, 76, 60, 0.3);
}

.btn-icon-delete:hover {
    background: rgba(231, 76, 60, 0.1);
    border-color: var(--danger);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.2);
}

/* =============================================
   FORM INPUTS
   ============================================= */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 0.9rem;
    border: 1.5px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.form-input.is-invalid {
    border-color: var(--danger);
    animation: shake 0.4s ease;
}

.form-input-sm {
    padding: 7px 12px;
    font-size: 0.82rem;
}

select.form-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234a5568' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-5px);
    }

    40%,
    80% {
        transform: translateX(5px);
    }
}

/* =============================================
   MODAL SYSTEM (No library)
   ============================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

/* Member & Delete modals must stack above Manage Members modal */
#memberModalOverlay,
#deleteConfirmOverlay {
    z-index: 1010;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    width: 420px;
    max-width: 92vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.92) translateY(16px);
    transition: transform 0.25s ease;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.glass-modal {
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-lg);
    box-shadow:
        0 20px 60px rgba(31, 38, 135, 0.18),
        0 0 0 1px rgba(255, 255, 255, 0.25);
}

.modal-lg {
    width: 680px;
}

.modal-sm {
    width: 360px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 10px;
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    font-size: 1.3rem;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    line-height: 1;
}

.btn-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.modal-body {
    padding: 16px 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-body-manage {
    padding: 0;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 24px 20px;
}

.modal-footer-between {
    justify-content: space-between;
}

/* =============================================
   TABLE
   ============================================= */
.manage-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar-left .form-input {
    width: 200px;
}

.toolbar-left select.form-input {
    width: 150px;
}

.table-wrap {
    overflow-y: auto;
    max-height: 50vh;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.data-table th {
    background: rgba(0, 0, 0, 0.03);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.text-right {
    text-align: right;
}

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

.text-small {
    font-size: 0.82rem;
}

.text-danger {
    color: var(--danger);
}

/* Cell helpers */
.cell-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cell-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cell-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid;
}

.cell-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.empty-table-msg {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
}

/* =============================================
   SEAT MAP
   ============================================= */
.seat-map-container {
    perspective: 1000px;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.seat-grid {
    display: grid;
    gap: 12px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-xl);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    transition: all 0.5s ease;
    width: 100%;
    height: 100%;
    overflow: auto;
    align-content: center;
    justify-content: center;
}

.seat-item {
    min-width: 80px;
    min-height: 60px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.seat-item:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.9);
    z-index: 10;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.seat-number-badge {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.6rem;
    opacity: 0.5;
    font-weight: bold;
    color: var(--text-secondary);
}

.team-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: absolute;
    top: 8px;
    right: 8px;
}

.member-name {
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
    margin-bottom: 4px;
    pointer-events: none;
    color: var(--text-primary);
}

.member-role {
    font-size: 0.7rem;
    opacity: 0.7;
    pointer-events: none;
    color: var(--text-secondary);
}

.special-zone {
    background: rgba(255, 255, 255, 0.5);
    border: 2px dashed rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-weight: 600;
}

.empty-seat {
    opacity: 0.6;
    border-style: dashed;
    background: rgba(0, 0, 0, 0.02);
}

.seat-item[draggable="true"] {
    cursor: grab;
}

.seat-item.dragging {
    opacity: 0.4;
    cursor: grabbing;
    transform: scale(0.95);
}

.seat-item.drag-over {
    outline: 2px dashed var(--primary);
    outline-offset: -2px;
    background: rgba(102, 126, 234, 0.15);
    transform: scale(1.08);
    z-index: 11;
}

.placeholder-text {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
}

.placeholder-text h3 {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* =============================================
   SIDEBAR TEAM CARDS
   ============================================= */
.team-card {
    margin-bottom: 10px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 0, 0, 0.07);
    background: rgba(255, 255, 255, 0.45);
    overflow: hidden;
    transition: box-shadow var(--transition);
}

.team-card:hover {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.team-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
}

.team-card-header:hover {
    background: rgba(0, 0, 0, 0.03);
}

.team-card-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.team-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.team-card-name {
    font-weight: 500;
    font-size: 0.88rem;
}

.team-card-count {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 20px;
}

.team-card-body {
    display: none;
    padding: 6px 12px 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.team-card-body.open {
    display: block;
}

.team-member-item {
    padding: 4px 0 4px 22px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    min-width: 260px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    opacity: 0;
    transform: translateX(40px);
    animation: toastIn 0.35s ease forwards;
}

.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

.toast-success {
    background: var(--success);
}

.toast-danger {
    background: var(--danger);
}

.toast .toast-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.1rem;
    cursor: pointer;
    margin-left: 12px;
    padding: 0 2px;
    line-height: 1;
}

.toast .toast-close:hover {
    color: #fff;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

/* =============================================
   SCROLLBAR
   ============================================= */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}