/* ==========================================
   MeowBoard - shared styles (login, control panel, developer panel)
   ========================================== */

:root {
    --bg-app: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --bg-hover: rgba(255, 255, 255, 0.05);

    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --ring: #8b5cf6;
    --secondary: #475569;
    --secondary-hover: #3f4b5e;
    --success: #22c55e;
    --success-hover: #16a34a;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-hover: #dc2626;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --bg-subtle: rgb(255 255 255 / 0.08);

    /* Coloured texts (status tags, messages) */
    --text-danger: #fca5a5;
    --text-warning: #fde68a;
    --text-recall: #fcd34d;
    --text-info: #bfdbfe;
    --text-judge: #93c5fd;
    --text-ring: #c4b5fd;
    --text-success: #86efac;

    --radius: 10px;
    --shadow: 0 4px 12px rgb(0 0 0 / 0.35);
    --font-family: 'Inter Variable', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* {
    box-sizing: border-box;
}

/* Light theme (chosen in Impostazioni): same layout, light colours */
:root[data-theme='light'] {
    --bg-app: #f1f5f9;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: rgb(15 23 42 / 0.04);
    --bg-subtle: rgb(15 23 42 / 0.06);

    --secondary: #64748b;
    --secondary-hover: #475569;

    --text-main: #0f172a;
    --text-muted: #475569;
    --border: #cbd5e1;
    --shadow: 0 4px 12px rgb(15 23 42 / 0.12);

    --text-danger: #b91c1c;
    --text-warning: #92400e;
    --text-recall: #b45309;
    --text-info: #1d4ed8;
    --text-judge: #1d4ed8;
    --text-ring: #6d28d9;
    --text-success: #15803d;
}

html {
    color-scheme: dark;
}

html[data-theme='light'] {
    color-scheme: light;
}

body {
    margin: 0;
    font-family: var(--font-family);
    font-size: 15px;
    line-height: 1.4;
    background: var(--bg-app);
    color: var(--text-main);
}

.hidden {
    display: none !important;
}

/* === Icons === */
.icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.icon svg {
    width: 18px;
    height: 18px;
}

/* === Forms === */
label.field {
    display: block;
    margin-bottom: 14px;
}

label.field > span {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='date'],
input[type='search'],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-main);
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.2);
}

textarea {
    resize: vertical;
}

input[type='checkbox'] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Hide the number spinners: operators type the number */
input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type='number'] {
    -moz-appearance: textfield;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:focus-visible,
.icon-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-block {
    width: 100%;
}

.btn-large {
    padding: 14px 18px;
    font-size: 17px;
}

.btn-small {
    padding: 6px 10px;
    font-size: 13px;
}

.btn-primary {
    background: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

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

.btn-success:hover:not(:disabled) {
    background: var(--success-hover);
}

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

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
}

.btn-warning {
    background: var(--warning);
    color: #111;
}

.btn-secondary {
    background: var(--secondary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary-hover);
}

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

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-main);
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

.card-body {
    padding: 18px;
}

/* === Brand === */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand .logo {
    display: flex;
    color: var(--primary);
}

.brand .logo svg {
    width: 24px;
    height: 24px;
}

.brand h1 {
    margin: 0;
    font-size: 19px;
    font-weight: 800;
}

/* === Messages === */
.message {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
}

.message-error {
    background: rgb(239 68 68 / 0.15);
    color: var(--text-danger);
}

.message-info {
    background: rgb(59 130 246 / 0.15);
    color: var(--text-info);
}

/* === Toasts === */
.toast-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(380px, calc(100vw - 40px));
}

.toast {
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    background: var(--bg-card);
    box-shadow: var(--shadow);
    font-weight: 600;
    transition: opacity 0.3s;
}

.toast-success {
    border-left-color: var(--success);
}

.toast-error {
    border-left-color: var(--danger);
}

.toast-warning {
    border-left-color: var(--warning);
}

/* === Dialogs (confirmations) === */
dialog {
    width: min(460px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: var(--shadow);
}

/*
 * A dialog never grows past the screen: its content scrolls inside, while the
 * row of buttons at the bottom (Chiudi, Salva...) always stays visible.
 */
dialog[open] {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 32px);
    overflow: hidden;
}

dialog[open] > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

dialog .dialog-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

dialog .dialog-actions {
    flex-shrink: 0;
}

dialog::backdrop {
    background: rgb(2 6 23 / 0.7);
}

.dialog-body {
    padding: 20px;
}

.dialog-body h3 {
    margin: 0 0 10px;
    font-size: 18px;
}

.dialog-body p {
    margin: 0 0 8px;
    color: var(--text-muted);
    white-space: pre-line;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

/* === Scrollbars === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
