/* ============================================================
   URL Shortener — Design System
   Tema: industriale/utilitario con accento arancio bruciato
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=Syne:wght@400;600;800&display=swap');

:root {
    --bg:        #0f0f0f;
    --surface:   #1a1a1a;
    --surface2:  #242424;
    --border:    #2e2e2e;
    --text:      #e8e6e1;
    --muted:     #6b7280;
    --accent:    #e8631a;
    --accent-lt: #f4844a;
    --danger:    #e74c3c;
    --success:   #27ae60;
    --radius:    6px;
    --mono:      'IBM Plex Mono', monospace;
    --sans:      'Syne', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    line-height: 1.6;
    min-height: 100vh;
}

/* ---------- Layout ---------- */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ---------- Nav ---------- */
nav {
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    height: 56px;
}

nav .logo {
    font-family: var(--mono);
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: -0.5px;
}

nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.15s;
}
nav a:hover { color: var(--text); }

/* ---------- Typography ---------- */
h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.2;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 1rem;
}

.mono { font-family: var(--mono); letter-spacing: -1px; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="email"],
input[type="tel"] {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.9rem;
    padding: 0.65rem 0.9rem;
    transition: border-color 0.15s;
    outline: none;
}

input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent)22;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    font-family: var(--sans);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-lt); border-color: var(--accent-lt); }

.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border-color: transparent;
}
.btn-ghost:hover { color: var(--text); }

/* ---------- Alerts ---------- */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    border-left: 3px solid;
}
.alert-error   { background: var(--danger)15; border-color: var(--danger);  color: #fca5a5; }
.alert-success { background: var(--success)15; border-color: var(--success); color: #86efac; }

/* ---------- Hero (stats search) ---------- */
.hero {
    padding: 3rem 0 2rem;
    text-align: center;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    max-width: 480px;
    margin: 0 auto;
}

.search-form input { flex: 1; }

/* ---------- Stats Header ---------- */
.stats-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.stats-header h1 {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 0.3rem;
}

.long-url {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.8rem;
    text-decoration: none;
    word-break: break-all;
}
.long-url:hover { color: var(--accent); }

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    align-items: center;
}

/* ---------- KPI Grid ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.kpi-card.accent {
    border-color: var(--accent)55;
    background: var(--accent)0d;
}

.kpi-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.kpi-value {
    font-family: var(--mono);
    font-size: 2rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
}

.kpi-card.accent .kpi-value { color: var(--accent); }

/* ---------- Charts Grid ---------- */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.chart-card.wide { grid-column: 1 / -1; }

.chart-card canvas { max-height: 220px; }

/* ---------- Data lists ---------- */
.data-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.data-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}

.data-label {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 75%;
}

.data-count {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--accent);
    flex-shrink: 0;
}

/* ---------- Misc ---------- */
.hint { color: var(--muted); font-size: 0.875rem; margin-top: 1.5rem; }
.hint a { color: var(--accent); text-decoration: none; }
.hint a:hover { text-decoration: underline; }

.empty { color: var(--muted); font-size: 0.875rem; font-style: italic; }

.meta {
    color: var(--muted);
    font-size: 0.8rem;
    font-family: var(--mono);
    margin-top: 1rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    h1 { font-size: 1.5rem; }
    .stats-header h1 { font-size: 1.75rem; }
    .charts-grid { grid-template-columns: 1fr; }
    .chart-card.wide { grid-column: 1; }
    .search-form { flex-direction: column; }
}

/* ---------- Login ---------- */
.login-logo {
    font-family: var(--mono);
    font-size: 1.5rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 1rem;
}

/* ---------- Data Table ---------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }

.table-title {
    display: block;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Alert success ---------- */
.alert-success { background: var(--success)15; border-color: var(--success); color: #86efac; }

/* ---------- QR Panel ---------- */
#qr-panel canvas { image-rendering: pixelated; }

/* ---------- Form layout a due colonne ---------- */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 560px) {
    .form-row { grid-template-columns: 1fr; }
}

.section-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}

/* ---------- QR Preset buttons ---------- */
.qr-presets {
    display: flex;
    gap: .5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.qr-preset {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--muted);
    font-size: .78rem;
    font-family: var(--sans);
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, color .15s;
    user-select: none;
}

.qr-preset:hover  { border-color: var(--accent); color: var(--text); }
.qr-preset.active { border-color: var(--accent); color: var(--accent); background: var(--accent)15; }

.qr-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* ---------- QR Preset buttons ---------- */
.qr-presets {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.qr-preset {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    background: var(--surface2);
    transition: border-color .15s, transform .1s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.qr-preset:hover  { border-color: var(--accent); transform: scale(1.08); }
.qr-preset.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent)33; }

.qr-preset input[type="color"] {
    width: 100%;
    height: 100%;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
}
