/* ============================================================
   COURSE PORTAL - STYLESHEET
   Design system allineato a federicobiasutti.com
   ============================================================ */

/* ── VARIABILI ─────────────────────────────────────────────── */
:root {
    --fb-primary: #2563eb;
    --fb-primary-dark: #1e40af;
    --fb-dark: #0f172a;
    --fb-text: #475569;
    --fb-bg: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    --fb-border: #e5e7eb;
    --fb-success: #16a34a;
    --fb-error: #dc2626;
    --fb-warning: #d97706;
    --fb-info: #2563eb;
    --radius-lg: 14px;
    --radius-md: 10px;
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.08);
}

/* ── RESET & BASE ──────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--fb-dark);
    background: var(--fb-bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--fb-primary);
    text-decoration: none;
}

a:hover {
    color: var(--fb-primary-dark);
}

/* ── CONTAINER ─────────────────────────────────────────────── */
.container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ── NAVBAR ────────────────────────────────────────────────── */
.navbar {
    background: #fff;
    border-bottom: 1px solid var(--fb-border);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.navbar-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-logo-img {
    width: 32px;
    height: auto;
}

.navbar-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--fb-dark);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-user {
    font-size: 14px;
    color: var(--fb-text);
}

/* ── BADGE ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-admin {
    background: #eff6ff;
    color: var(--fb-primary);
    border: 1px solid #bfdbfe;
}

/* ── BOTTONI ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: 999px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--fb-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--fb-primary-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

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

.btn-outline:hover {
    border-color: var(--fb-primary);
    color: var(--fb-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--fb-text);
    padding: 6px 10px;
}

.btn-ghost:hover {
    background: #f1f5f9;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-full {
    width: 100%;
}

.btn-danger-text {
    color: var(--fb-error);
}

.btn-danger-text:hover {
    background: #fef2f2;
    color: var(--fb-error);
}

/* ── CARD ──────────────────────────────────────────────────── */
.card {
    background: #fff;
    border: 1px solid var(--fb-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ── LOGIN PAGE ────────────────────────────────────────────── */
.login-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 60px);
    padding: 40px 20px;
}

.login-card {
    background: #fff;
    border: 1px solid var(--fb-border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}

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

.login-logo {
    width: 72px;
    height: auto;
    margin-bottom: 20px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--fb-dark);
    margin-bottom: 2px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--fb-text);
}

/* ── FORM ──────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--fb-dark);
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="file"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--fb-border);
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--fb-dark);
    background: #fff;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--fb-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input[type="file"] {
    padding: 8px 10px;
}

.form-group-btn {
    flex: 0 0 auto;
    margin-bottom: 16px;
}

/* ── SECTION DIVIDER (stile sito principale) ─────────────── */
.section {
    margin-bottom: 40px;
}

.section-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.section-bar {
    width: 4px;
    height: 28px;
    background: var(--fb-primary);
    border-radius: 2px;
    flex-shrink: 0;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--fb-dark);
}

/* ── WELCOME CARD ──────────────────────────────────────────── */
.welcome-card {
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-lg);
    padding: 32px;
    margin: 32px 0;
}

.welcome-card h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--fb-dark);
    margin-bottom: 8px;
}

.welcome-card p {
    font-size: 15px;
    color: var(--fb-text);
    line-height: 1.6;
}

/* ── TABELLA ───────────────────────────────────────────────── */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--fb-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 14px;
    border-bottom: 2px solid var(--fb-border);
}

.table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
    color: var(--fb-dark);
    vertical-align: middle;
}

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

.table tbody tr:hover {
    background: #f8fafc;
}

.actions-cell {
    white-space: nowrap;
}

/* Valori segreti */
.secret-value {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: var(--fb-text);
    word-break: break-all;
}

/* ── DOCUMENTI ─────────────────────────────────────────────── */
.documents-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.document-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px;
}

.document-card:hover {
    transform: translateY(-2px);
}

.document-info {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.document-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.document-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--fb-dark);
    word-break: break-word;
}

.document-desc {
    font-size: 13px;
    color: var(--fb-text);
    margin-top: 2px;
}

.document-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

/* ── FORM CARD (admin) ─────────────────────────────────────── */
.form-card {
    margin-top: 16px;
}

.form-card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

.form-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--fb-dark);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f5f9;
}

/* ── MODAL ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-card {
    width: 100%;
    max-width: 460px;
}

.modal-card:hover {
    transform: none;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ── ALERT / FLASH MESSAGES ────────────────────────────────── */
.alert {
    position: relative;
    padding: 12px 40px 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    margin-top: 16px;
    border: 1px solid;
}

.alert-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.alert-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.alert-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.alert-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

.alert-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
}

.alert-close:hover {
    opacity: 1;
}

/* ── EMPTY STATE ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 24px;
    color: var(--fb-text);
}

.empty-state:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

/* ── ACCESS TOGGLE (admin) ─────────────────────────────────── */
.access-toggle-card {
    border-left: 4px solid var(--fb-primary);
}

.access-toggle-card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

.access-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.access-toggle-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--fb-dark);
    margin-bottom: 4px;
}

.access-toggle-desc {
    font-size: 13px;
    color: var(--fb-text);
}

.access-toggle-control {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.access-toggle-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-active {
    background: #f0fdf4;
    color: var(--fb-success);
    border: 1px solid #bbf7d0;
}

.badge-inactive {
    background: #fef2f2;
    color: var(--fb-error);
    border: 1px solid #fecaca;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 999px;
    transition: background 0.25s ease;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--fb-success);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

/* ── CREDENTIAL CARDS ─────────────────────────────────────── */
.credentials-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.credential-card {
    padding: 20px 24px;
}

.credential-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.credential-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-api_key {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-account {
    background: #ede9fe;
    color: #5b21b6;
    border: 1px solid #c4b5fd;
}

.badge-generic {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.credential-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--fb-dark);
    margin-bottom: 12px;
}

.credential-notes {
    font-size: 13px;
    color: var(--fb-text);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f1f5f9;
    font-style: italic;
}

.credential-link {
    font-size: 13px;
    word-break: break-all;
}

.credential-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
}

/* ── SECRET ROW ───────────────────────────────────────────── */
.secret-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.secret-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--fb-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 80px;
    flex-shrink: 0;
}

.secret-value {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: var(--fb-text);
    word-break: break-all;
    flex: 1;
}

/* ── TAG SYSTEM ───────────────────────────────────────────── */
.tag-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 28px;
    padding: 14px 20px;
    background: #fff;
    border: 1px solid var(--fb-border);
    border-radius: var(--radius-lg);
}

.tag-filter-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--fb-text);
    margin-right: 4px;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 14px;
    border-radius: 999px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--fb-border);
    background: #fff;
    color: var(--fb-text);
    cursor: pointer;
    transition: all 0.15s ease;
}

.tag-chip:hover {
    border-color: var(--fb-primary);
    color: var(--fb-primary);
}

.tag-chip-active {
    background: var(--fb-primary);
    color: #fff;
    border-color: var(--fb-primary);
}

.tag-chip-active:hover {
    background: var(--fb-primary-dark);
    color: #fff;
    border-color: var(--fb-primary-dark);
}

.tag-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    background: #eff6ff;
    color: var(--fb-primary);
    border: 1px solid #bfdbfe;
}

.credential-tags,
.document-tags {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.document-tags {
    margin-top: 6px;
}

/* ── TYPE SELECTOR (admin form) ───────────────────────────── */
.type-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.type-option {
    cursor: pointer;
}

.type-option input {
    display: none;
}

.type-option-label {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--fb-border);
    background: #fff;
    transition: all 0.15s ease;
}

.type-option input:checked + .type-option-label {
    border-color: var(--fb-primary);
    background: #eff6ff;
    color: var(--fb-primary);
}

.type-option-label:hover {
    border-color: var(--fb-primary);
}

/* ── FORM ROW (non nested in .inline-form) ────────────────── */
.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.label-hint {
    font-weight: 400;
    color: var(--fb-text);
    font-size: 12px;
}

/* ── MODAL LARGE ──────────────────────────────────────────── */
.modal-card-lg {
    max-width: 560px;
}

/* ── FOOTER ────────────────────────────────────────────────── */
.footer {
    margin-top: auto;
    padding: 24px 0;
    text-align: center;
    font-size: 13px;
    color: var(--fb-text);
    border-top: 1px solid var(--fb-border);
}

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 640px) {
    .login-card {
        padding: 32px 24px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-group-btn {
        margin-bottom: 0;
    }

    .document-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .document-actions {
        width: 100%;
    }

    .navbar-user {
        display: none;
    }

    .table th,
    .table td {
        padding: 10px 8px;
        font-size: 13px;
    }

    .welcome-card {
        padding: 24px 20px;
        margin: 20px 0;
    }

    .welcome-card h1 {
        font-size: 18px;
    }

    .secret-row {
        flex-wrap: wrap;
    }

    .secret-label {
        min-width: 70px;
    }

    .access-toggle-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .tag-filter-bar {
        padding: 10px 14px;
    }

    .modal-card-lg {
        max-width: 100%;
    }
}
