:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #dddddd;
    --accent-color: #3498db;
    --success-color: #2ecc71;
    --warning-color: #f1c40f;
    --danger-color: #e74c3c;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --border-color: #404040;
    --accent-color: #4fa3e3;
    --shadow: 0 2px 4px rgba(0,0,0,0.3);
}

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

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: var(--transition);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-header {
    background-color: var(--bg-primary);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    position: relative;
}

.main-header h1 {
    color: var(--text-primary);
    font-size: 1.5em;
    text-align: center;
}

.theme-switch {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8em;
    opacity: 0.7;
}

.theme-switch:hover { opacity: 1; }
.theme-switch input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.stats-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-primary);
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: var(--transition);
}

.stat-card:hover { transform: translateY(-2px); }
.stat-card h3 {
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-size: 0.9em;
}

.stat-card p {
    color: var(--text-primary);
    font-size: 1.3em;
    font-weight: bold;
}

.content-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 20px;
    flex: 1;
}

.list-section, .form-section {
    background-color: var(--bg-primary);
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.form-section {
    height: fit-content;
    position: sticky;
    top: 20px;
}

.filters-container {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: var(--bg-secondary);
    padding: 15px;
    border-radius: 8px;
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9em;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.status-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85em;
    transition: var(--transition);
    min-width: 100px;
    text-align: center;
}

.filter-btn:hover, .filter-btn.active {
    background: var(--accent-color);
    color: white;
}

.table-container {
    overflow-x: auto;
    background-color: var(--bg-primary);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85em;
    background-color: var(--bg-primary);
    vertical-align: middle;
}

th {
    background-color: var(--bg-secondary);
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 10;
}

tr:hover td { background-color: var(--bg-secondary); }

/* Larghezze colonne */
table th:nth-child(1), table td:nth-child(1) { width: 40px; text-align: center; }
table th:nth-child(2), table td:nth-child(2) { width: 25%; }
table th:nth-child(3), table td:nth-child(3) { width: 200px; }
table th:nth-child(4), table td:nth-child(4) { width: 60px; text-align: center; }
table th:nth-child(5), table td:nth-child(5) { width: 110px; text-align: center; }
table th:nth-child(6), table td:nth-child(6) { width: 150px; text-align: center; }
table th:nth-child(7), table td:nth-child(7) { width: 80px; padding: 8px 4px; }

.file-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.file-link {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 0.85em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

.file-link:hover { text-decoration: underline; }
.file-link:before {
    content: "🔊";
    font-size: 1em;
    flex-shrink: 0;
}

.audio-player {
    padding: 2px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.mini-player {
    height: 24px;
    width: 160px;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}
/* Nasconde i controlli del volume */
.mini-player::-webkit-media-controls-volume-slider,
.mini-player::-webkit-media-controls-mute-button,
.mini-player::-webkit-media-controls-volume-control-container {
    display: none !important;
}

/* Firefox */
.mini-player::-moz-range-thumb {
    display: none !important;
}

/* Stile base del player */
audio {
    filter: sepia(20%) saturate(70%) grayscale(1) contrast(99%) invert(12%);
}

[data-theme="dark"] audio {
    filter: sepia(20%) saturate(70%) grayscale(1) contrast(99%) invert(88%);
}

/* Container del player */
.audio-player {
    padding: 2px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    max-width: fit-content;
}

/* Responsive */
@media (max-width: 768px) {
    .mini-player {
        width: 140px;
    }
}

@media (max-width: 576px) {
    .audio-player {
        display: none; /* Nascondi su schermi molto piccoli */
    }
}

.mini-player:hover { opacity: 1; }

.actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 70px;
}

.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary { background-color: var(--accent-color); color: white; }
.btn-primary:hover { background-color: #2980b9; }
.btn-secondary { background-color: var(--text-secondary); color: white; }
.btn-secondary:hover { background-color: #4a4a4a; }

.btn-edit, .btn-delete {
    padding: 4px 8px;
    font-size: 0.75em;
    width: 100%;
    text-align: center;
}

.btn-edit { background-color: var(--warning-color); color: #000; }
.btn-edit:hover { background-color: #e3b505; }
.btn-delete { background-color: var(--danger-color); color: white; }
.btn-delete:hover { background-color: #c82333; }

.status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 500;
    display: inline-block;
    min-width: 90px;
    text-align: center;
}

.status-inattesa { background-color: var(--warning-color); color: #000; }
.status-inlavorazione { background-color: var(--accent-color); color: white; }
.status-completato { background-color: var(--success-color); color: white; }

.form-group { margin-bottom: 12px; }

label {
    display: block;
    margin-bottom: 4px;
    font-weight: bold;
    color: var(--text-primary);
    font-size: 0.9em;
}

input, textarea, select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9em;
    transition: var(--transition);
}

select {
    appearance: none;
    padding-right: 30px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 1em;
    cursor: pointer;
}

textarea { resize: vertical; min-height: 60px; }
.readonly-field { background-color: var(--bg-secondary); cursor: not-allowed; }

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
    padding: 10px;
}

.btn-pagination {
    padding: 6px 12px;
    font-size: 0.85em;
    min-width: 100px;
    text-align: center;
}

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

.message {
    padding: 8px 12px;
    margin-bottom: 10px;
    border-radius: 4px;
    font-size: 0.9em;
}

.message-success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.message-error { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

.main-footer {
    margin-top: 30px;
    padding: 15px;
    text-align: center;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    font-size: 0.85em;
}

.disclaimer {
    margin-top: 5px;
    font-size: 0.85em;
    color: var(--danger-color);
}

@media (max-width: 992px) {
    .content-grid { grid-template-columns: 1fr; }
    .form-section { position: static; }
    .mini-player { width: 150px; }
}

@media (max-width: 768px) {
    .container { padding: 10px; }
    .status-filters { flex-direction: column; }
    .filter-btn { width: 100%; }
    .pagination { flex-direction: column; gap: 10px; }
    .theme-switch { position: static; justify-content: center; margin-top: 10px; }
    th, td { padding: 8px; font-size: 0.8em; }
    .actions { min-width: 60px; }
    .btn-edit, .btn-delete { padding: 3px 6px; font-size: 0.7em; }
}

@media (max-width: 576px) {
    .main-header h1 { font-size: 1.3em; }
    .audio-player { display: none; }
    .stat-card p { font-size: 1.1em; }
    table th:nth-child(6), table td:nth-child(6) { display: none; }
}

.hidden { display: none; }

/* Loading Spinner */
.loading-spinner {
    border: 3px solid var(--bg-secondary);
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 15px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Animazioni */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

/* Scrollbar personalizzata */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Focus states */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Selezione testo */
::selection {
    background-color: var(--accent-color);
    color: white;
}

/* Stati disabilitati */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Fix per browser specifici */
/* Safari fixes */
@supports (-webkit-touch-callout: none) {
    .content-grid {
        gap: 15px;
    }
    
    select {
        background-color: var(--bg-primary) !important;
    }

    .audio-player {
        -webkit-appearance: none;
    }
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--text-secondary) var(--bg-secondary);
}

/* Audio player customization */
audio::-webkit-media-controls-panel {
    background-color: var(--bg-secondary);
}

audio::-webkit-media-controls-current-time-display,
audio::-webkit-media-controls-time-remaining-display {
    color: var(--text-primary);
}

/* Touch device optimizations */
@media (hover: none) {
    .btn:hover {
        transform: none;
    }
    
    .stat-card:hover {
        transform: none;
    }
}

/* Print styles */
@media print {
    .theme-switch,
    .btn-edit,
    .btn-delete,
    .audio-player {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .container {
        padding: 0;
    }

    .main-header {
        box-shadow: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --shadow: none;
    }

    .status,
    .btn {
        border: 1px solid currentColor;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Error states */
.has-error {
    border-color: var(--danger-color);
}

.error-message {
    color: var(--danger-color);
    font-size: 0.8em;
    margin-top: 4px;
}

/* Loading states */
.is-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.is-loading::after {
    content: '';
    position: absolute;
    top: calc(50% - 0.5em);
    left: calc(50% - 0.5em);
    width: 1em;
    height: 1em;
    border: 2px solid var(--bg-secondary);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.login-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.login-form {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-form .form-container {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    background: var(--background-secondary);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.title-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.title {
    font-weight: bold;
}

.voice-name {
    font-size: 0.85em;
    color: #888;
    font-style: italic;
}