/* ==========================================================================
   Kikiva'O GF - Style Paperboard / Tableau blanc
   ========================================================================== */

/* -- Google Fonts (handwritten feel) -- */
@import url('https://fonts.googleapis.com/css2?family=Patrick+Hand&family=Inter:wght@400;500;600&display=swap');

/* -- Variables -- */
:root {
    --bg-board: #f5f0e8;
    --bg-cork: #d4a76a;
    --bg-column: rgba(255, 255, 255, 0.6);
    --bg-card: #fffde7;
    --bg-card-driver: #e8f5e9;
    --bg-card-hover: #fff9c4;
    --bg-seat-empty: rgba(255, 255, 255, 0.7);
    --bg-seat-taken: #c8e6c9;
    --border-card: #c9b99a;
    --border-column: #b8a88a;
    --text-primary: #3e2723;
    --text-secondary: #5d4037;
    --text-light: #8d6e63;
    --accent-primary: #ff7043;
    --accent-secondary: #66bb6a;
    --accent-danger: #ef5350;
    --shadow-card: 2px 3px 8px rgba(0,0,0,0.12);
    --shadow-drag: 4px 6px 16px rgba(0,0,0,0.25);
    --font-hand: 'Patrick Hand', cursive;
    --font-ui: 'Inter', sans-serif;
    --radius: 6px;
    --transition: 0.2s ease;
}

/* -- Reset & Base -- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-ui);
    background: var(--bg-board);
    background-image:
        radial-gradient(circle at 20% 50%, rgba(212,167,106,0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255,112,67,0.08) 0%, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: auto;
}

/* Texture papier subtile */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

/* -- Header -- */
.board-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #5d4037, #4e342e);
    color: #fff;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.board-header h1 {
    font-family: var(--font-hand);
    font-size: 1.8rem;
    letter-spacing: 1px;
    white-space: nowrap;
}

.board-header .subtitle {
    font-size: 0.85rem;
    opacity: 0.8;
    flex: 1;
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* -- Buttons -- */
.btn {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-primary);
    color: #fff;
}
.btn-primary:hover { background: #f4511e; transform: translateY(-1px); }

.btn-secondary {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
}
.btn-secondary:hover { background: rgba(255,255,255,0.3); }

.btn-ghost {
    background: transparent;
    color: inherit;
    opacity: 0.7;
}
.btn-ghost:hover { opacity: 1; }

.btn-danger {
    background: var(--accent-danger);
    color: #fff;
}
.btn-danger:hover { background: #d32f2f; }

.btn-small {
    font-size: 0.75rem;
    padding: 4px 10px;
}

/* -- Board Layout -- */
.board {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 20px;
    padding: 24px;
    min-height: calc(100vh - 70px);
    overflow-x: auto;
    align-items: flex-start;
}

/* -- Columns (Lieux) -- */
.board-column {
    flex: 0 0 280px;
    min-width: 280px;
    background: var(--bg-column);
    border: 2px dashed var(--border-column);
    border-radius: 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    transition: border-color var(--transition), background var(--transition);
}

.board-column.drag-over {
    border-color: var(--accent-primary);
    background: rgba(255, 112, 67, 0.08);
}

.column-header {
    padding: 14px 16px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.column-header h2 {
    font-family: var(--font-hand);
    font-size: 1.3rem;
    color: var(--text-secondary);
    flex: 1;
}

.card-count::after {
    content: attr(data-count);
    display: inline-block;
    background: var(--accent-primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    border-radius: 50%;
}

.card-list {
    padding: 12px;
    min-height: 80px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* -- User Cards -- */
.user-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow-card);
    cursor: grab;
    transition: transform var(--transition), box-shadow var(--transition);
    position: relative;
    /* Légère rotation aléatoire appliquée via JS */
}

.user-card:hover {
    transform: translateY(-2px) rotate(0deg) !important;
    box-shadow: var(--shadow-drag);
    background: var(--bg-card-hover);
}

.user-card:active {
    cursor: grabbing;
}

.user-card.is-driver {
    background: var(--bg-card-driver);
    border-color: #a5d6a7;
}

/* Pin decoratif */
.user-card::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    background: radial-gradient(circle at 40% 40%, #ff8a65, #d84315);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.card-username {
    font-family: var(--font-hand);
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 4px;
    padding-top: 4px;
}

.card-info {
    font-size: 0.75rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-info .vehicle-icon {
    font-size: 1rem;
}

.card-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition);
    color: var(--accent-danger);
    padding: 2px 4px;
    line-height: 1;
}

.user-card:hover .card-delete {
    opacity: 0.6;
}
.card-delete:hover {
    opacity: 1 !important;
}

/* -- Seat Slots (emplacements passager) -- */
.seat-slots {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.seat-slot {
    background: var(--bg-seat-empty);
    border: 2px dashed #c8e6c9;
    border-radius: 4px;
    padding: 8px 10px;
    min-height: 38px;
    font-family: var(--font-hand);
    font-size: 0.9rem;
    color: var(--text-light);
    text-align: center;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.seat-slot.seat-empty {
    font-style: italic;
}

.seat-slot.seat-empty::before {
    content: 'Place libre';
}

.seat-slot.seat-taken {
    background: var(--bg-seat-taken);
    border-style: solid;
    border-color: #81c784;
    color: var(--text-primary);
    font-weight: 500;
}

.seat-slot.drag-over-seat {
    border-color: var(--accent-primary);
    background: rgba(255, 112, 67, 0.12);
}

.seat-passenger-name {
    flex: 1;
}

.seat-eject {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--accent-danger);
    opacity: 0.5;
    padding: 2px;
}
.seat-eject:hover {
    opacity: 1;
}

/* -- Drag States -- */
.sortable-ghost {
    opacity: 0.4;
}

.sortable-chosen {
    transform: rotate(0deg) !important;
    box-shadow: var(--shadow-drag);
}

.sortable-drag {
    transform: rotate(2deg) !important;
    box-shadow: var(--shadow-drag);
}

/* -- Modals -- */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(62, 39, 35, 0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.paper-card {
    background: #fffef6;
    border: 1px solid var(--border-card);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 4px 6px 20px rgba(0,0,0,0.15);
}

.paper-card h3 {
    font-family: var(--font-hand);
    font-size: 1.5rem;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

/* -- Forms -- */
.form-group {
    margin-bottom: 14px;
}

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

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #d7ccc8;
    border-radius: var(--radius);
    font-family: var(--font-hand);
    font-size: 1.1rem;
    background: #fff;
    color: var(--text-primary);
    transition: border-color var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 6px;
    vertical-align: middle;
    accent-color: var(--accent-secondary);
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px;
}

/* -- Admin Panel -- */
.admin-section {
    margin-bottom: 18px;
}

.admin-section h4 {
    font-family: var(--font-hand);
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

#admin-locations-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#admin-locations-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: rgba(255,255,255,0.5);
    border-radius: 4px;
    font-size: 0.9rem;
}

#admin-locations-list .btn-delete-location {
    background: none;
    border: none;
    color: var(--accent-danger);
    cursor: pointer;
    font-size: 0.85rem;
    opacity: 0.6;
}
#admin-locations-list .btn-delete-location:hover {
    opacity: 1;
}

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

.toast {
    padding: 12px 18px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    max-width: 320px;
}

.toast-success { background: #43a047; }
.toast-error { background: #e53935; }
.toast-info { background: #5d4037; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(10px); }
}

/* -- Responsive -- */
@media (max-width: 768px) {
    .board-header {
        padding: 10px 16px;
    }

    .board-header h1 {
        font-size: 1.3rem;
    }

    .board-header .subtitle {
        display: none;
    }

    .board {
        flex-direction: column;
        padding: 12px;
        gap: 16px;
    }

    .board-column {
        flex: none;
        min-width: auto;
        width: 100%;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
    }

    .btn {
        padding: 10px 14px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .board-header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .modal-content {
        max-width: 100%;
    }

    .paper-card {
        padding: 18px;
    }
}

/* -- Scrollbar custom -- */
::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.05);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(93, 64, 55, 0.3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(93, 64, 55, 0.5);
}
