/* ==========================================================================
   Groupes - Styles specific to the Groupes page
   Extends the base En Classe styles (styles.css)
   ========================================================================== */

/* ===== CSS Custom Properties for Groupes ===== */
:root {
    --g-accent: #06b6d4;
    --g-accent-soft: rgba(6, 182, 212, 0.08);
    --g-accent-mid: rgba(6, 182, 212, 0.2);
    --g-surface: #ffffff;
    --g-bg: #f6f8fa;
    --g-text: #1e293b;
    --g-text-light: #64748b;
    --g-border: #e2e8f0;
    --g-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --g-shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --g-radius: 10px;
    --g-radius-sm: 6px;
    --g-transition: 0.2s ease;
    --g-group-card-width: 304px;
}

html.dark-mode,
body.dark-mode {
    --g-accent: #22d3ee;
    --g-accent-soft: rgba(34, 211, 238, 0.12);
    --g-accent-mid: rgba(34, 211, 238, 0.25);
    --g-surface: #2d2d2d;
    --g-bg: #1a1a1a;
    --g-text: #e8e8e8;
    --g-text-light: #a0a0a0;
    --g-border: #444444;
    --g-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --g-shadow-lg: 0 10px 25px rgba(0,0,0,0.3);
}

/* ===== TITLE SPACING ===== */
.site-title {
    margin-bottom: var(--spacing-2xl, 3rem);
}

/* ===== TAB BAR ===== */
#tab-bar {
    display: flex;
    justify-content: center;
    gap: 0;
    background: var(--g-surface);
    padding: 0 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 1000px;
    width: 100%;
    border-radius: var(--g-radius) var(--g-radius) 0 0;
    box-shadow: var(--g-shadow);
}

#tab-bar::-webkit-scrollbar {
    display: none;
}

.tab {
    padding: 10px 18px;
    border: none;
    background: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--g-text-light);
    cursor: pointer;
    transition: all var(--g-transition);
    white-space: nowrap;
    position: relative;
    font-family: inherit;
    border-radius: var(--g-radius-sm);
    margin: 4px 0;
}

.tab:hover {
    color: var(--g-text);
    background: var(--g-accent-soft);
}

.tab.active {
    color: var(--g-accent);
    background: var(--g-accent-soft);
    font-weight: 600;
}

/* ===== TOOLBAR ===== */
#toolbar {
    display: flex;
    gap: 8px;
    padding: 0.75rem 1.5rem;
    background: var(--g-surface);
    border-top: 1px solid var(--g-border);
    border-bottom: 2px solid var(--g-accent);
    flex-wrap: wrap;
    max-width: 1000px;
    width: 100%;
    justify-content: center;
    border-radius: 0 0 var(--g-radius) var(--g-radius);
    box-shadow: var(--g-shadow);
}

#toolbar button {
    padding: 8px 14px;
    border: 1px solid var(--g-border);
    border-radius: var(--g-radius-sm);
    background: var(--g-surface);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--g-transition);
    color: var(--g-text);
    font-weight: 500;
    font-family: inherit;
}

#toolbar button:hover {
    background: var(--g-surface);
    color: var(--g-text);
    border-color: var(--g-accent);
    transform: translateY(-1px);
    box-shadow: var(--g-shadow);
}

/* ===== MAIN CONTENT ===== */
#content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 24px 16px;
    min-height: 0;
    width: 100%;
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

/* ===== VIEWS ===== */
.view {
    display: none;
}

.view.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    animation: g-fadeIn 0.3s ease;
}

@keyframes g-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== SPINNER ===== */
.spinner-container {
    position: relative;
    width: min(78vw, 620px);
    height: min(78vw, 620px);
    max-width: 90vw;
    max-height: 90vw;
    will-change: transform;
    cursor: pointer;
}

.spinner-container.spinning {
    cursor: progress;
}

.spinner-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    margin-top: 38px;
}

.spinner-result-slot {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(78vw, 620px);
    max-width: 90vw;
}

#wheel-canvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: 0 4px 30px rgba(0,0,0,0.15), inset 0 0 0 4px var(--g-accent-mid);
    transform-origin: center;
}

#wheel-pointer {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.7rem;
    color: var(--g-accent);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    z-index: 10;
    line-height: 1;
}

#spinner-result {
    display: flex;
    align-items: center;
    gap: 14px;
    position: static;
    max-width: calc(100% - 4px);
    padding: 12px 18px;
    background: var(--g-surface);
    color: var(--g-text);
    border: 2px solid var(--g-accent);
    border-radius: var(--g-radius);
    font-size: 1.25rem;
    font-weight: 700;
    box-shadow: var(--g-shadow-lg);
    animation: g-popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes g-popIn {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

#spinner-result.hidden {
    display: flex;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

#btn-remove-name {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--g-accent);
    border-radius: var(--g-radius-sm);
    background: var(--g-surface);
    color: var(--g-text);
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--g-transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#btn-remove-name:hover {
    background: var(--g-accent-soft);
    border-color: var(--g-accent);
}

#btn-remove-name i {
    margin-right: 0;
}

.big-btn {
    padding: 16px 40px;
    border: 1px solid var(--g-accent);
    border-radius: var(--g-radius);
    background: var(--g-surface);
    color: var(--g-text);
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--g-transition);
    box-shadow: var(--g-shadow);
}

.big-btn:hover {
    background: var(--g-accent-soft);
    border-color: var(--g-accent);
    transform: translateY(-2px);
    box-shadow: var(--g-shadow-lg);
}

.big-btn:active {
    transform: translateY(0);
}

/* ===== SINGLE NAME ===== */
#single-view.active {
    display: grid;
    grid-template-columns: 56px 1fr 56px;
    align-items: center;
    gap: 18px;
    min-height: 0;
    padding-top: 0;
    max-width: 700px;
    margin-inline: auto;
    width: 100%;
}

.name-display {
    font-size: clamp(3.2rem, 9vw, 7.2rem);
    font-weight: 800;
    color: var(--g-accent);
    text-align: center;
    padding: 20px 0;
    min-width: 0;
    animation: g-fadeIn 0.3s ease;
    user-select: none;
    letter-spacing: -0.02em;
    line-height: 1.1;
    will-change: transform;
}

.nav-arrow {
    width: 56px;
    height: 56px;
    border: 2px solid var(--g-border);
    border-radius: 50%;
    background: var(--g-surface);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--g-transition);
    color: var(--g-text-light);
    flex-shrink: 0;
}

.nav-arrow:hover {
    background: var(--g-surface);
    color: var(--g-text);
    border-color: var(--g-accent);
    transform: scale(1.1);
}

/* ===== LINEUP ===== */
#lineup-view.active {
    display: grid;
    grid-template-columns: 56px 1fr 56px;
    align-items: start;
    gap: 18px;
    padding-top: 18px;
    max-width: 700px;
    margin-inline: auto;
    width: 100%;
}

#groups-view,
#teams-view,
#chart-view {
    padding-top: 18px;
}

#lineup-container {
    text-align: center;
    min-width: 0;
}

#lineup-current {
    font-size: 3rem;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--g-surface);
    color: var(--g-text);
    border: 2px solid var(--g-accent);
    border-radius: var(--g-radius);
    box-shadow: var(--g-shadow-lg);
}

#lineup-list {
    list-style: none;
    counter-reset: lineup;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 400px;
    margin: 0 auto;
    padding: 0;
}

#lineup-list li {
    counter-increment: lineup;
    padding: 10px 16px;
    background: var(--g-surface);
    border: 1px solid var(--g-border);
    border-radius: var(--g-radius-sm);
    font-size: 1rem;
    text-align: left;
    transition: all var(--g-transition);
}

#lineup-list li::before {
    content: counter(lineup) ". ";
    font-weight: 700;
    color: var(--g-accent);
    margin-right: 4px;
}

#lineup-list li.is-current {
    background: var(--g-accent-soft);
    color: var(--g-text);
    font-weight: 600;
    border-color: var(--g-accent);
    transform: scale(1.02);
}

#lineup-list li.is-current::before {
    color: var(--g-accent);
}

/* ===== GROUPS & TEAMS ===== */
.group-controls {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.group-controls label {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    color: var(--g-text);
}

.group-controls select {
    padding: 10px 14px;
    border: 1px solid var(--g-border);
    border-radius: var(--g-radius-sm);
    font-size: 1rem;
    background: var(--g-surface);
    color: var(--g-text);
    cursor: pointer;
}

.group-controls button {
    padding: 10px 18px;
    border: 1px solid var(--g-border);
    border-radius: var(--g-radius-sm);
    background: var(--g-surface);
    color: var(--g-text);
    cursor: pointer;
    font-size: 0.98rem;
    transition: all var(--g-transition);
    font-family: inherit;
}

.group-controls button:hover {
    background: var(--g-surface);
    color: var(--g-text);
    border-color: var(--g-accent);
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--g-group-card-width), var(--g-group-card-width)));
    gap: 20px;
    justify-content: center;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
}

.group-card {
    background: var(--g-surface);
    border: 1px solid var(--g-border);
    border-top: 3px solid var(--card-accent, var(--g-accent));
    border-radius: var(--g-radius);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    min-width: 0;
    width: var(--g-group-card-width);
    max-width: var(--g-group-card-width);
    display: flex;
    flex-direction: column;
    animation: g-fadeIn 0.3s ease;
    transition: transform var(--g-transition);
}

.group-card:hover {
    transform: translateY(-2px);
}

.group-card-header {
    padding: 12px 18px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--g-text);
    background: color-mix(in srgb, var(--card-tint, #f6fbfe) 42%, var(--g-surface));
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    text-align: center;
}

body.dark-mode .group-card-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.group-card-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.group-member {
    padding: 10px 14px;
    background: var(--g-bg);
    border-radius: var(--g-radius-sm);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--g-transition);
    border: 2px solid transparent;
    color: var(--g-text);
}

.group-member:hover {
    border-color: var(--g-accent);
    background: var(--g-accent-soft);
}

.group-member.selected {
    border-color: var(--g-accent);
    background: var(--g-accent-soft);
    box-shadow: 0 0 0 2px var(--g-accent-mid);
}

/* ===== CHART / SEATING ===== */
.chart-controls {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.chart-controls label {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1rem;
    color: var(--g-text);
}

.chart-controls input[type="number"] {
    width: 66px;
    padding: 8px 10px;
    border: 1px solid var(--g-border);
    border-radius: var(--g-radius-sm);
    font-size: 1rem;
    text-align: center;
    background: var(--g-surface);
    color: var(--g-text);
}

body.dark-mode .chart-controls input[type="number"] {
    color-scheme: dark;
}

.chart-controls button {
    padding: 10px 18px;
    border: 1px solid var(--g-border);
    border-radius: var(--g-radius-sm);
    background: var(--g-surface);
    color: var(--g-text);
    cursor: pointer;
    font-size: 0.98rem;
    transition: all var(--g-transition);
    font-family: inherit;
}

.chart-controls button:hover {
    background: var(--g-surface);
    color: var(--g-text);
    border-color: var(--g-accent);
}

#chart-container {
    display: grid;
    gap: 24px;
    justify-content: center;
    padding: 32px 24px;
    width: 100%;
    max-width: 1180px;
}

.chart-cell {
    padding: 10px 10px 8px;
    background: transparent;
    border: none;
    border-radius: var(--g-radius-sm);
    cursor: pointer;
    transition: all var(--g-transition);
    min-height: 104px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    overflow: hidden;
}

.chart-seat-layout {
    width: 100%;
    display: block;
    max-width: 220px;
}

.chart-desk {
    width: 100%;
    min-height: 62px;
    padding: 10px 8px;
    background: color-mix(in srgb, var(--cell-tint, #f3f8fc) 28%, var(--g-surface));
    border: 2px solid rgba(51, 65, 85, 0.32);
    border-top: 3px solid var(--cell-accent, var(--g-accent));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
}

body.dark-mode .chart-desk {
    background: color-mix(in srgb, var(--cell-tint, rgba(255,255,255,0.06)) 24%, var(--g-surface));
    border-color: color-mix(in srgb, var(--cell-accent, var(--g-accent)) 38%, rgba(255, 255, 255, 0.14));
    border-top-color: var(--cell-accent, var(--g-accent));
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.24), 0 1px 3px rgba(0, 0, 0, 0.2);
}

.chart-seat-name {
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--g-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.chart-cell:hover {
    transform: translateY(-2px);
}

.chart-cell:hover .chart-desk {
    border-color: var(--cell-accent, var(--g-accent));
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.chart-cell.selected {
    transform: translateY(-1px);
}

.chart-cell.selected .chart-desk {
    border-color: var(--cell-accent, var(--g-accent));
    box-shadow: 0 0 0 3px var(--g-accent-mid);
}

.chart-cell.empty {
    cursor: default;
}

.chart-cell.empty .chart-desk {
    background: var(--g-bg);
    border-style: dashed;
    border-top-style: dashed;
    border-color: rgba(100, 116, 139, 0.45);
}

.chart-cell.empty .chart-seat-name {
    color: var(--g-text-light);
}

.chart-cell.empty:hover {
    transform: none;
}

.chart-cell.empty:hover .chart-desk {
    box-shadow: var(--g-shadow);
}

/* ===== MODAL ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: g-fadeIn 0.2s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--g-surface);
    border-radius: var(--g-radius);
    padding: 28px;
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--g-shadow-lg);
}

.modal-content h2 {
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: var(--g-text);
    text-align: left;
}

.modal-content p {
    color: var(--g-text-light);
    margin-bottom: 14px;
    font-size: 0.9rem;
}

#names-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--g-border);
    border-radius: var(--g-radius-sm);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    line-height: 1.6;
    background: var(--g-surface);
    color: var(--g-text);
}

#names-textarea:focus {
    outline: none;
    border-color: var(--g-accent);
    box-shadow: 0 0 0 3px var(--g-accent-mid);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    justify-content: flex-end;
}

.modal-buttons button:not(.big-btn) {
    padding: 10px 20px;
    border: 1px solid var(--g-border);
    border-radius: var(--g-radius-sm);
    background: var(--g-surface);
    color: var(--g-text);
    cursor: pointer;
    font-size: 0.95rem;
    transition: all var(--g-transition);
    font-family: inherit;
}

.modal-buttons button:not(.big-btn):hover {
    background: var(--g-bg);
}

.modal-buttons .big-btn {
    padding: 10px 24px;
    font-size: 0.95rem;
}

/* ===== TOAST ===== */
#toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--g-surface);
    color: var(--g-text);
    border: 1px solid var(--g-accent);
    padding: 12px 28px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: var(--g-shadow-lg);
    z-index: 2000;
    animation: g-toastIn 0.3s ease;
}

#toast.hidden {
    display: none;
}

@keyframes g-toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== SPINNER VIEW ===== */
#spinner-view {
    flex: 1 0 auto;
    min-height: 0;
    justify-content: center;
    padding-top: 0;
}

/* ===== BUTTON RIPPLE ===== */
#content button,
#toolbar button,
#tab-bar button {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(6, 182, 212, 0.18);
    transform: scale(0);
    animation: g-rippleExpand 520ms ease-out;
    pointer-events: none;
    z-index: 0;
}

body.dark-mode .ripple {
    background: rgba(34, 211, 238, 0.2);
}

#content button > *,
#toolbar button > *,
#tab-bar button > * {
    position: relative;
    z-index: 1;
}

@keyframes g-rippleExpand {
    to {
        transform: scale(1);
        opacity: 0;
    }
}

#toolbar button i,
.group-controls button i,
.chart-controls button i {
    margin-right: 0.45rem;
}

.nav-arrow i {
    margin-right: 0;
}

#btn-remove-name i {
    margin-right: 0;
}

/* ===== FULLSCREEN ===== */
body.fullscreen .main-nav,
body.fullscreen .site-title,
body.fullscreen #tab-bar,
body.fullscreen #toolbar,
body.fullscreen footer {
    display: none;
}

body.fullscreen #content {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    :root {
        --g-group-card-width: 240px;
    }

    .name-display {
        font-size: clamp(2.2rem, 9vw, 3.5rem);
        padding: 24px 0;
    }

    #lineup-current {
        font-size: 2rem;
    }

    .spinner-container {
        width: min(88vw, 430px);
        height: min(88vw, 430px);
    }

    .cards-container {
        gap: 14px;
    }

    #chart-container {
        gap: 16px;
        padding: 16px 10px;
    }

    .chart-cell {
        min-height: 92px;
        font-size: 0.94rem;
        padding: 8px 6px 6px;
    }

    #toolbar {
        padding: 8px 12px;
        gap: 6px;
    }

    #toolbar button {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .tab {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    :root {
        --g-group-card-width: min(88vw, 320px);
    }

    .name-display {
        font-size: 1.9rem;
        padding: 16px 0;
    }

    #single-view.active,
    #lineup-view.active {
        grid-template-columns: 44px 1fr 44px;
    }

    .spinner-container {
        width: min(92vw, 330px);
        height: min(92vw, 330px);
    }

    .nav-arrow {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }

}

/* ===== Dark mode card tint adjustments ===== */
body.dark-mode .group-card {
    background: var(--g-surface);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.24), 0 1px 3px rgba(0, 0, 0, 0.2);
}

body.dark-mode .group-card-header {
    background: color-mix(in srgb, var(--card-tint, rgba(255,255,255,0.06)) 30%, var(--g-surface));
}
