/* Base & Variables */
:root {
    --bg: #0f172a;
    --card: #1e293b;
    --primary: #8b5cf6;
    --text: #f8fafc;
    --accent: #10b981;
    --warning: #f59e0b;
    --red: #ef4444;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    padding: 2rem 0;
    margin: 0;
    font-size: 16px;
    line-height: 1.5;
}

h1,
h2 {
    font-family: 'Outfit', sans-serif;
    margin-top: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Navigation */
.nav {
    margin-bottom: 2rem;
    display: flex;
    gap: 2rem;
    align-items: center;
    background: var(--card);
    padding: 1rem 1.5rem;
    border-radius: 0.8rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.nav-group {
    position: relative;
    display: inline-block;
}

.nav-group-label {
    cursor: pointer;
    opacity: 0.7;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: 0.2s;
    padding: 0.5rem 0;
}

.nav-group:hover .nav-group-label {
    opacity: 1;
    color: var(--primary);
}

.dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--card);
    border: 1px solid #334155;
    border-radius: 0.5rem;
    min-width: 200px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow: hidden;
}

.nav-group:hover .dropdown {
    display: block;
}

.dropdown a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.8;
    transition: 0.2s;
}

.dropdown a:hover {
    background: rgba(139, 92, 246, 0.1);
    opacity: 1;
    color: var(--primary);
}

.dropdown a+a {
    border-top: 1px solid #334155;
}

.nav a.home-link {
    font-weight: 700;
    color: var(--primary);
    opacity: 1;
    text-decoration: none;
}

/* Components */
.card {
    background: var(--card);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    border: none;
    background: var(--primary);
    color: white;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: 0.2s;
    gap: 0.5rem;
    font-family: inherit;
    font-size: 0.95rem;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

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

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

.btn-link {
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    opacity: 0.7;
    font-weight: 600;
    transition: 0.2s;
}

.btn-link:hover {
    opacity: 1;
    color: var(--primary);
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-client {
    background: #3b82f6;
}

.badge-staff {
    background: #f59e0b;
}

.messages {
    margin-bottom: 1.5rem;
}

.message {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    background: var(--accent);
    color: white;
}

.message.warning {
    background: var(--warning);
}

.message.error {
    background: var(--red);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th {
    text-align: left;
    opacity: 0.6;
    font-size: 0.8rem;
    text-transform: uppercase;
    padding: 1rem;
}

td {
    padding: 1rem;
    border-top: 1px solid #334155;
}

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

select,
input,
textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #334155;
    background: #0f172a;
    color: white;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

label {
    display: block;
    margin-top: 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.8;
}

.helptext {
    font-size: 0.75rem;
    opacity: 0.5;
    margin-top: 0.25rem;
    display: block;
}

.errorlist {
    color: var(--red);
    font-size: 0.8rem;
    list-style: none;
    padding: 0;
}

/* Tom Select Dark Theme */
.ts-control,
.ts-control input,
.ts-dropdown {
    background-color: #0f172a !important;
    color: white !important;
    border-color: #334155 !important;
}

.ts-dropdown .active {
    background-color: var(--primary) !important;
    color: white !important;
}

.ts-dropdown .option:hover {
    background-color: rgba(139, 92, 246, 0.2) !important;
}

.ts-control .item {
    background: var(--primary) !important;
    color: white !important;
    border-radius: 4px !important;
}

.ts-wrapper.multi .ts-control>div {
    margin: 0 4px 4px 0 !important;
}

/* View Specific - Dashboard */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.stat {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0.5rem 0;
}

.text-neg {
    color: #f87171;
}

.text-pos {
    color: #34d399;
}

/* View Specific - Warehouse */
.stock-badge {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
    padding: 0.4rem 0.8rem;
    border-radius: 2rem;
    font-weight: 700;
    font-size: 0.9rem;
}

.price {
    font-weight: 600;
    opacity: 0.8;
}

.comic-title {
    font-weight: 700;
    color: var(--text);
    font-size: 1.1rem;
}

.comic-info {
    opacity: 0.6;
    font-size: 0.9rem;
    margin-top: 0.2rem;
}

.empty-state {
    text-align: center;
    padding: 4rem;
    opacity: 0.4;
    font-style: italic;
}

/* View Specific - User Form, Checkboxes & Tooltips */
.form-group.checkbox-group {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.form-group.checkbox-group label {
    margin: 0 !important;
    display: inline-block !important;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.8;
    line-height: normal;
}

.form-group.checkbox-group input[type="checkbox"] {
    width: auto !important;
    margin: 0 !important;
    margin-top: 0 !important;
    cursor: pointer;
}

.info-tooltip-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    cursor: help;
    color: var(--primary);
}

.info-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.info-tooltip-wrapper:hover .info-icon {
    opacity: 1;
}

.tooltip-text {
    visibility: hidden;
    width: 250px;
    background-color: #1e293b;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 0.75rem;
    position: absolute;
    z-index: 10;
    bottom: 125%;
    left: 50%;
    margin-left: -125px;
    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
    line-height: 1.4;
    pointer-events: none;
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #1e293b transparent transparent transparent;
}

.info-tooltip-wrapper:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.form-radio-container ul {
    display: flex;
    gap: 1.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
    margin-top: 0.5rem;
}

.form-radio-container li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.form-radio-container input {
    width: auto !important;
    cursor: pointer;
    margin-top: 0 !important;
}

/* View Specific - Bulk Import */
.grid-import {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

textarea.csv-editor {
    height: 300px;
    font-family: monospace;
}

.results {
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: 1rem;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid var(--primary);
}

.error-log {
    max-height: 200px;
    overflow-y: auto;
    background: #000;
    padding: 1rem;
    border-radius: 0.5rem;
    color: var(--red);
    font-family: monospace;
    font-size: 0.8rem;
    margin-top: 1rem;
}

/* View Specific - Bulk Subscription */
.card-narrow {
    max-width: 800px;
    margin: 4rem auto;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Common Layout Helpers */
.nav-actions {
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.subtitle {
    opacity: 0.6;
    margin-bottom: 2rem;
}

.trash-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Management Grids */
.management-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
}

.search-add-section {
    background: rgba(139, 92, 246, 0.05);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid rgba(139, 92, 246, 0.1);
    align-self: start;
}

.add-section {
    background: rgba(139, 92, 246, 0.1);
    padding: 1.5rem;
    border-radius: 1rem;
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

/* Centered Form Layout (Login, Collana/Editore Form) */
.centered-container {
    padding: 2rem;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.card-form {
    background: var(--card);
    border-radius: 1.5rem;
    padding: 2.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 500px;
}

.nav-back {
    text-align: center;
    margin-top: 1.5rem;
}

.nav-back a {
    color: var(--text);
    opacity: 0.5;
    text-decoration: none;
    font-size: 0.9rem;
}

.nav-back a:hover {
    opacity: 1;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--card);
    padding: 2.5rem;
    border-radius: 1.5rem;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid #334155;
    position: relative;
}

.modal-header {
    margin-bottom: 2rem;
    text-align: center;
}

.modal-header h2 {
    margin: 0;
    color: var(--primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* Clickable Credit */
.credit-clickable {
    cursor: pointer;
    color: var(--primary);
    font-weight: 700;
    border-bottom: 1px dashed var(--primary);
    transition: 0.2s;
    display: inline-block;
}

.credit-clickable:hover {
    opacity: 0.8;
}