/* ================================================================
   Area Riservata Commercialista - STARBUILD
   Tema chiaro professionale
   ================================================================ */

:root {
    --primary: #1877F2;
    --primary-dark: #166FE5;
    --primary-light: #E8F0FE;
    --bg-page: #F5F7FA;
    --bg-card: #FFFFFF;
    --bg-header: #1877F2;
    --text-primary: #1A1B21;
    --text-secondary: #6C7293;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --success: #10B981;
    --success-bg: #ECFDF5;
    --danger: #EF4444;
    --danger-bg: #FEF2F2;
    --warning: #F59E0B;
    --warning-bg: #FFFBEB;
    --info: #3B82F6;
    --info-bg: #EFF6FF;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-page);
    min-height: 100vh;
}

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

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

/* ================================================================
   LOGIN PAGE
   ================================================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #1877F2 100%);
    padding: 1rem;
}

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

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
}

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

.login-header .logo {
    margin-bottom: 1rem;
    display: inline-block;
}

.login-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.login-subtitle {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
}

.login-footer strong {
    color: white;
}

/* ================================================================
   FORM ELEMENTS
   ================================================================ */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-card);
    transition: var(--transition);
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.1);
}

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

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Password wrapper con occhiolino */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    padding-right: 3rem !important;
}

.password-toggle {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.password-toggle:hover {
    color: var(--primary);
}

/* ================================================================
   BUTTONS
   ================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    color: white;
}

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-page);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    color: var(--text-primary);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: 0.4rem;
    border-radius: 6px;
    background: none;
    border: none;
}

.btn-primary-icon {
    color: var(--primary);
}

.btn-primary-icon:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.btn-danger-icon {
    color: var(--danger);
}

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

.btn-header {
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 6px;
    font-size: 0.8rem;
}

.btn-header:hover {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

/* ================================================================
   ALERTS
   ================================================================ */

.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: var(--success-bg);
    color: #065F46;
    border-left: 4px solid var(--success);
}

.alert-error {
    background: var(--danger-bg);
    color: #991B1B;
    border-left: 4px solid var(--danger);
}

.alert-info {
    background: var(--info-bg);
    color: #1E40AF;
    border-left: 4px solid var(--info);
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 0 0.25rem;
    line-height: 1;
}

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

/* ================================================================
   HEADER
   ================================================================ */

.header {
    background: var(--bg-header);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-home-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: white;
}

.header-home-link:hover {
    color: white;
    opacity: 0.9;
}

.header-logo-img {
    height: 30px;
    width: auto;
    background: white;
    padding: 3px 6px;
    border-radius: 4px;
}

.header-title {
    font-size: 1rem;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.user-badge {
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-admin {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.badge-user {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
}

.badge-commercialista {
    background: rgba(16, 185, 129, 0.3);
    color: white;
}

/* ================================================================
   MAIN CONTENT
   ================================================================ */

.main-content {
    min-height: calc(100vh - 60px - 50px);
}

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

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

/* ================================================================
   PASSWORD CHANGE
   ================================================================ */

.password-change-container {
    display: flex;
    justify-content: center;
    padding-top: 2rem;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.card-centered {
    width: 100%;
    max-width: 460px;
    padding: 2rem;
}

.card-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
}

.card-header .text-muted {
    font-size: 0.85rem;
}

.card form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ================================================================
   BREADCRUMBS
   ================================================================ */

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 0;
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.breadcrumb-link {
    color: var(--primary);
    font-weight: 500;
}

.breadcrumb-link:hover {
    text-decoration: underline;
}

.breadcrumb-separator {
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 600;
}

/* ================================================================
   ADMIN TOOLBAR
   ================================================================ */

.admin-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.toolbar-section {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.toolbar-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

/* Upload Area */
.upload-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-area p {
    margin-top: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.upload-link {
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
}

.upload-link:hover {
    text-decoration: underline;
}

.file-input {
    display: none;
}

.upload-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--primary-light);
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--primary);
}

/* Create Folder */
.input-group {
    display: flex;
    gap: 0.5rem;
}

.input-group input {
    flex: 1;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition);
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.1);
}

/* ================================================================
   FILE BROWSER
   ================================================================ */

.file-browser {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.file-browser-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

.file-browser-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.file-browser-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.parent-folder-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 500;
}

.parent-folder-link:hover {
    text-decoration: underline;
    color: var(--primary-dark);
}

.file-table-wrapper {
    overflow-x: auto;
}

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

.file-table thead {
    background: var(--bg-page);
}

.file-table th {
    padding: 0.65rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

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

.file-table tbody tr:hover {
    background: var(--bg-page);
}

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

.col-icon {
    width: 40px;
    text-align: center;
}

.col-name {
    min-width: 200px;
}

.col-size {
    width: 100px;
    white-space: nowrap;
}

.col-date {
    width: 140px;
    white-space: nowrap;
}

.col-actions {
    width: 100px;
    text-align: right;
    white-space: nowrap;
}

.col-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
}

.folder-link {
    font-weight: 600;
    color: var(--primary);
}

.folder-link:hover {
    text-decoration: underline;
}

.file-name {
    color: var(--text-primary);
}

.file-name-link {
    color: var(--text-primary);
    font-weight: 500;
    text-decoration: none;
}

.file-name-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

.rename-link {
    font-size: 0.7rem;
    color: var(--primary);
    margin-left: 0.5rem;
    cursor: pointer;
    vertical-align: middle;
}

.rename-link:hover {
    text-decoration: underline;
    color: var(--primary-dark);
}

/* Checkbox selezione */
.col-check {
    width: 32px;
    text-align: center;
    padding-left: 0.5rem !important;
    padding-right: 0 !important;
}

.col-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

tr.row-selected {
    background: var(--primary-light) !important;
}

/* Drag & Drop */
tr[draggable="true"] {
    cursor: grab;
}

tr[draggable="true"]:active {
    cursor: grabbing;
}

tr.dragging {
    opacity: 0.4;
}

tr.drag-over-folder {
    background: var(--primary-light) !important;
    outline: 2px dashed var(--primary);
    outline-offset: -2px;
}

.inline-form {
    display: inline;
}

/* Empty state */
.empty-state {
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state p {
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* ================================================================
   OWNER TAG
   ================================================================ */

.owner-tag {
    display: inline-block;
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* ================================================================
   GESTIONE UTENTI
   ================================================================ */

.section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 0.5rem 0;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.card-full {
    width: 100%;
    padding: 0;
}

.card-body {
    padding: 1.25rem;
}

.card-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.form-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-group-inline {
    flex: 1;
    min-width: 150px;
}

.form-group-inline input,
.form-group-inline select {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition);
    background: var(--bg-card);
    color: var(--text-primary);
}

.form-group-inline input:focus,
.form-group-inline select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.1);
}

.create-user-form .btn {
    white-space: nowrap;
}

/* Role badges nella tabella utenti */
.role-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-badge-admin {
    background: var(--primary-light);
    color: var(--primary);
}

.role-badge-commercialista {
    background: var(--success-bg);
    color: #065F46;
}

.role-badge-user {
    background: var(--bg-page);
    color: var(--text-secondary);
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.status-active {
    background: var(--success-bg);
    color: #065F46;
}

.status-locked {
    background: var(--danger-bg);
    color: #991B1B;
}

.status-pending {
    background: var(--warning-bg);
    color: #92400E;
}

/* Bottone successo (sblocca) */
.btn-success-icon {
    color: var(--success);
}

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

/* ================================================================
   FOOTER
   ================================================================ */

.footer {
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-light);
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 768px) {
    .admin-toolbar {
        grid-template-columns: 1fr;
    }

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

    .section-header {
        flex-wrap: wrap;
    }

    .header-content {
        padding: 0 1rem;
    }

    .header-title {
        font-size: 0.85rem;
    }

    .header-user {
        display: none;
    }

    .container {
        padding: 1rem;
    }

    .login-card {
        padding: 1.75rem;
    }

    .file-table .col-date {
        display: none;
    }

    .col-name {
        min-width: 120px;
    }

    .breadcrumbs {
        font-size: 0.8rem;
    }

    .toolbar-section {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .file-table .col-size {
        display: none;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}
