/* ============================================
   MOTH — Arma 3 Group Portal
   Dark military theme
   ============================================ */

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

:root {
    --bg-primary:    #0d0d0d;
    --bg-secondary:  #141414;
    --bg-card:       #1e1e1e;
    --bg-card-hover: #252525;

    --accent:        #4CAF50;
    --accent-hover:  #43a047;
    --accent-dim:    rgba(76, 175, 80, 0.12);

    --text-primary:  #e8e8e8;
    --text-secondary:#a0a0a0;
    --text-muted:    #555;

    --border:        #272727;
    --border-light:  #333;

    --danger:        #ef5350;
    --warning:       #ffa726;
    --info:          #42a5f5;
    --success:       #4CAF50;

    --radius:        8px;
    --radius-lg:     12px;
    --transition:    0.18s ease;
    --shadow:        0 4px 20px rgba(0, 0, 0, 0.5);
    --shadow-lg:     0 8px 40px rgba(0, 0, 0, 0.7);
}

html { scroll-behavior: smooth; background: var(--bg-primary); }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: transparent;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* === Background canvas === */
#bg-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -1;
    pointer-events: none;
}

a { color: inherit; }

/* ===========================
   Layout
   =========================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.page-main {
    padding: 36px 0 64px;
}

/* ===========================
   Header
   =========================== */
.site-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo-icon {
    width: 34px;
    height: 34px;
    background: var(--accent);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 800;
    color: #000;
    letter-spacing: -0.05em;
    flex-shrink: 0;
}

.brand-name {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text-primary);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.user-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
}

.user-role {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 2px;
}

.user-role--chef {
    color: var(--danger);
}

.user-role--gestionnaire {
    color: var(--warning);
}

.user-role--lieutenant {
    color: var(--info);
}

.user-role--membre {
    color: var(--success);
}

/* ===========================
   Typography
   =========================== */
h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.page-title {
    font-size: 26px;
    margin-bottom: 6px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
}

.section-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

/* ===========================
   Buttons
   =========================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(76,175,80,0.35);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-light);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

.btn-danger {
    background: rgba(239, 83, 80, 0.1);
    color: var(--danger);
    border-color: rgba(239, 83, 80, 0.3);
}
.btn-danger:hover:not(:disabled) {
    background: rgba(239, 83, 80, 0.2);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
    border-color: var(--border-light);
}

.btn-sm   { padding: 6px 12px; font-size: 12px; }
.btn-lg   { padding: 12px 28px; font-size: 15px; }
.btn-full { width: 100%; }

/* ===========================
   Cards
   =========================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input,
.form-select {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

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

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-select option { background: #1a1a1a; }

/* ===========================
   Tables
   =========================== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    min-width: 500px;
}

thead { background: var(--bg-secondary); }

th {
    padding: 11px 16px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: rgba(255,255,255,0.015); }

/* ===========================
   Badges
   =========================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    border: 1px solid;
    white-space: nowrap;
}

.badge-danger  { background: rgba(239,83,80,.12);  color: var(--danger);   border-color: rgba(239,83,80,.3); }
.badge-warning { background: rgba(255,167,38,.12); color: var(--warning); border-color: rgba(255,167,38,.3); }
.badge-info    { background: rgba(66,165,245,.12); color: var(--info);    border-color: rgba(66,165,245,.3); }
.badge-success { background: rgba(76,175,80,.12);  color: var(--success); border-color: rgba(76,175,80,.3); }
.badge-muted   { background: rgba(255,255,255,.04); color: var(--text-muted); border-color: var(--border); }

/* ===========================
   Dashboard Tiles
   =========================== */
.tiles-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 8px;
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.tile::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent);
    opacity: 0;
    transition: opacity var(--transition);
}

.tile:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.tile:hover::before { opacity: 1; }

.tile-icon {
    width: 46px;
    height: 46px;
    background: var(--accent-dim);
    border: 1px solid rgba(76, 175, 80, 0.25);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.tile-icon.red {
    background: rgba(239, 83, 80, 0.1);
    border-color: rgba(239, 83, 80, 0.25);
}

.tile-name {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.tile-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    flex: 1;
}

/* ===========================
   Filter Bar
   =========================== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.filter-btn {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

/* ===========================
   Resource Cards
   =========================== */
.resources-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.resource-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition);
}

.resource-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.resource-card-img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
    background: var(--bg-secondary);
}

.resource-card-placeholder {
    width: 100%;
    height: 180px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.resource-card-body { padding: 18px 20px; }

.resource-card-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.resource-card-coords {
    font-size: 12px;
    color: var(--accent);
    font-family: 'Courier New', monospace;
    margin-bottom: 6px;
    letter-spacing: 0.04em;
}

.resource-card-category {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.resource-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-top: 8px;
}

/* ===========================
   Info Cards
   =========================== */
.infos-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    padding: 22px 24px;
    transition: border-color var(--transition);
}

.info-card:hover { border-left-color: var(--accent-hover); }

.info-card-category {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: 8px;
}

.info-card-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 12px;
}

.info-card-content {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.75;
    white-space: pre-wrap;
}

/* ===========================
   Login
   =========================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(76, 175, 80, 0.04) 0%, transparent 50%),
        var(--bg-primary);
}

.login-box {
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo {
    width: 68px;
    height: 68px;
    background: var(--accent);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: 800;
    color: #000;
    letter-spacing: -0.05em;
    margin: 0 auto 20px;
    box-shadow: 0 8px 32px rgba(76, 175, 80, 0.4);
}

.login-title {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

.login-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
}

/* ===========================
   Alerts & Messages
   =========================== */
.error-message {
    background: rgba(239, 83, 80, 0.08);
    border: 1px solid rgba(239, 83, 80, 0.3);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    color: var(--danger);
    margin-bottom: 20px;
    display: none;
}

.error-message.visible { display: block; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid;
}

.alert-success {
    background: rgba(76, 175, 80, 0.08);
    border-color: rgba(76, 175, 80, 0.3);
    color: var(--success);
}

.alert-error {
    background: rgba(239, 83, 80, 0.08);
    border-color: rgba(239, 83, 80, 0.3);
    color: var(--danger);
}

/* ===========================
   Loading & Empty States
   =========================== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 56px 24px;
    color: var(--text-muted);
    font-size: 13px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
    flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 64px 24px;
}

.empty-state-icon {
    font-size: 44px;
    display: block;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-state-sub {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===========================
   Misc
   =========================== */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    margin-bottom: 24px;
    transition: color var(--transition);
}

.back-link:hover { color: var(--accent); }

.price {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
}

.text-muted { color: var(--text-muted); }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }

/* ===========================
   Responsive
   =========================== */
@media (max-width: 900px) {
    .tiles-grid { grid-template-columns: repeat(2, 1fr); }
    .resources-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .tiles-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .resources-grid { grid-template-columns: 1fr; }
    .tile { padding: 20px 16px; }
    .tile-name { font-size: 14px; }
    .tile-desc { font-size: 12px; }
    .tile-icon { width: 38px; height: 38px; font-size: 17px; }
    .page-title { font-size: 20px; }
    .page-subtitle { font-size: 13px; margin-bottom: 20px; }
    .container { padding: 0 16px; }
    .page-main { padding: 24px 0 48px; }
    .login-form { padding: 24px; }
    .login-title { font-size: 24px; }

    /* Header */
    .site-header { padding: 10px 0; }
    .logo-icon { width: 30px; height: 30px; font-size: 13px; }
    .brand-name { font-size: 15px; }
    .header-brand { gap: 8px; }
    .header-user { gap: 10px; }
    .user-name { font-size: 12px; }
    .user-role { font-size: 10px; }

    /* Cards */
    .card { padding: 16px; }
    .card-header { padding-bottom: 12px; margin-bottom: 14px; }
    .card-title { font-size: 14px; }

    /* Section header stacks vertically */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    /* Tables: tighter cells */
    th { padding: 8px 10px; font-size: 9px; }
    td { padding: 10px; font-size: 13px; }
    table { min-width: 420px; }

    /* Filter buttons */
    .filter-bar { gap: 6px; }
    .filter-btn { padding: 6px 12px; font-size: 12px; }

    /* Buttons */
    .btn { padding: 8px 14px; font-size: 13px; }
    .btn-sm { padding: 6px 10px; font-size: 11px; }

    /* Resource cards */
    .resource-card-img,
    .resource-card-placeholder { height: 140px; }
    .resource-card-body { padding: 14px 16px; }
    .resource-card-name { font-size: 14px; }

    /* Back link */
    .back-link { margin-bottom: 16px; }
}

@media (max-width: 400px) {
    .tiles-grid { grid-template-columns: 1fr; }
    .header-user .user-info { display: none; }
    .container { padding: 0 12px; }
    .card { padding: 14px; }
    .login-form { padding: 18px; }
    .login-logo { width: 56px; height: 56px; font-size: 24px; }
    .login-title { font-size: 22px; }
}
