/* ===== DESIGN SYSTEM ===== */
:root {
    --primary: #2563eb;
    --primary-light: #eff6ff;
    --primary-dark: #1e40af;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --success: #10b981;
    
    --light: #f9fafb;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --text: #1f2937;
    --text-muted: #6b7280;
    
    --radius: 6px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text);
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

/* ===== CONTAINER ===== */
.ccdr-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 20px;
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.4s ease;
}

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

header {
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 20px;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}

header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* ===== TABS ===== */
.ccdr-tabs {
    display: flex;
    gap: 12px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 30px;
    background: var(--light);
    padding: 12px;
    border-radius: var(--radius-lg);
}

.ccdr-tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: var(--radius);
    transition: var(--transition);
    position: relative;
}

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

.ccdr-tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow);
}

.ccdr-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.ccdr-tab-content.active {
    display: block;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: white;
    color: var(--text);
    border: 1.5px solid var(--border);
}

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

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* ===== CARDS ===== */
.ccdr-meeting-card {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
    overflow: hidden;
    position: relative;
}

.ccdr-meeting-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--info) 100%);
}

.ccdr-meeting-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
}

.ccdr-meeting-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}

.ccdr-meeting-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.ccdr-meeting-card-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--primary-light);
    color: var(--primary);
}

.ccdr-meeting-card-badge.scheduled {
    background: #dbeafe;
    color: var(--info);
}

.ccdr-meeting-card-badge.ongoing {
    background: #fee2e2;
    color: var(--danger);
}

.ccdr-meeting-card-badge.closed {
    background: #dcfce7;
    color: var(--success);
}

.ccdr-meeting-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.ccdr-meeting-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ccdr-meetings-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 20px;
}

/* ===== FORMS ===== */
.ccdr-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.ccdr-form-section {
    border: none;
    padding: 20px;
    background: var(--light);
    border-radius: var(--radius-lg);
}

.ccdr-form-section legend {
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}

.ccdr-form-section legend h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--primary);
}

.ccdr-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.ccdr-form-group input,
.ccdr-form-group textarea,
.ccdr-form-group select {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
}

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

.ccdr-form-group textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

.ccdr-radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ccdr-radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    cursor: pointer;
}

.ccdr-radio-group input[type="radio"],
.ccdr-radio-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.ccdr-form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 12px;
}

/* ===== MODAL ===== */
.ccdr-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ccdr-modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.ccdr-modal-content {
    background: white;
    border-radius: var(--radius-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.ccdr-modal-large {
    max-width: 900px;
}

.ccdr-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--light);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-muted);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ccdr-modal-close:hover {
    background: var(--danger);
    color: white;
}

.ccdr-modal-content h2 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 20px;
    font-weight: 700;
}

/* ===== TABLES ===== */
.ccdr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.ccdr-table thead {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    font-weight: 600;
}

.ccdr-table th,
.ccdr-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.ccdr-table tbody tr:hover {
    background: var(--primary-light);
}

.ccdr-table tbody tr:nth-child(even) {
    background: var(--light);
}

/* ===== ALERTS ===== */
.ccdr-alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

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

.ccdr-alert-success {
    background: #dcfce7;
    color: #15803d;
    border-left: 4px solid var(--success);
}

.ccdr-alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.ccdr-alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning);
}

.ccdr-alert-info {
    background: #dbeafe;
    color: #0c4a6e;
    border-left: 4px solid var(--info);
}

/* ===== DETAILS ===== */
.ccdr-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

.ccdr-detail-section {
    background: linear-gradient(135deg, var(--light) 0%, #ffffff 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
}

.ccdr-detail-section:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.ccdr-detail-section h3 {
    font-size: 0.95rem;
    margin-bottom: 16px;
}

.ccdr-detail-item {
    margin-bottom: 16px;
}

.ccdr-detail-item strong {
    display: block;
    color: var(--text);
    margin-bottom: 6px;
    font-weight: 600;
}

.ccdr-detail-item p {
    color: var(--text-muted);
    margin: 0;
    padding: 8px 12px;
    background: white;
    border-left: 3px solid var(--primary);
    border-radius: 4px;
    word-break: break-word;
}

.ccdr-link {
    display: inline-block;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 12px;
    background: var(--primary-light);
    border-radius: 4px;
    transition: var(--transition);
    word-break: break-all;
    overflow-wrap: break-word;
}

.ccdr-link:hover {
    background: var(--primary);
    color: white;
}

/* ===== PRESENCES ===== */
.ccdr-status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.ccdr-status-presente {
    background-color: #dcfce7;
    color: #15803d;
}

.ccdr-status-assente {
    background-color: #fee2e2;
    color: #991b1b;
}

.ccdr-status-giustificato {
    background-color: #fef3c7;
    color: #92400e;
}

/* ===== PRESENCES MATRIX ===== */
.ccdr-presences-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: white;
    box-shadow: var(--shadow);
}

.ccdr-presences-matrix {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.ccdr-presences-matrix thead {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    font-weight: 600;
}

.ccdr-presences-matrix th {
    padding: 12px 8px;
    text-align: center;
    white-space: nowrap;
}

.ccdr-presences-matrix td {
    padding: 12px 8px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-size: 1.2em;
}

.ccdr-presences-matrix tbody tr:hover {
    background-color: var(--primary-light);
}

/* ===== ABSENCES ===== */
.ccdr-absences-container {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
}

.ccdr-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px;
    background: var(--light);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.ccdr-legend > div {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.ccdr-user-absences-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ccdr-absence-item {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    transition: var(--transition);
}

.ccdr-absence-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.ccdr-absence-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}

.ccdr-absence-item h4 {
    margin: 0 0 4px 0;
    color: var(--text);
    font-size: 1rem;
}

/* ===== AGENDA ===== */
.ccdr-agenda-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ccdr-agenda-item {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    transition: var(--transition);
}

.ccdr-agenda-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.ccdr-agenda-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.ccdr-agenda-item-header h4 {
    margin: 0;
    color: var(--text);
    font-size: 1rem;
}

.ccdr-agenda-status-select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    background: white;
    cursor: pointer;
    transition: var(--transition);
}

.ccdr-agenda-status-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.ccdr-agenda-item-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 8px 0 0 0;
    line-height: 1.5;
}

/* ===== MANAGE TABS ===== */
.ccdr-manage-tabs {
    display: flex;
    gap: 12px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
    background: var(--light);
    padding: 12px;
    border-radius: var(--radius-lg);
}

.ccdr-manage-tab-btn {
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 500;
    border-radius: var(--radius);
    transition: var(--transition);
}

.ccdr-manage-tab-btn:hover {
    background: white;
    color: var(--primary);
}

.ccdr-manage-tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow);
}

.ccdr-manage-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.ccdr-manage-content.active {
    display: block;
}

.ccdr-manage-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ===== LOADING SPINNER ===== */
.ccdr-spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(2px);
}

.ccdr-spinner-overlay.active {
    opacity: 1;
    visibility: visible;
}

.ccdr-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    background: white;
    padding: 40px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    text-align: center;
}

.ccdr-spinner-circle {
    width: 60px;
    height: 60px;
    border: 5px solid #f0f0f0;
    border-top-color: var(--primary);
    border-right-color: var(--primary);
    border-radius: 50%;
    animation: ccdr-spin 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

.ccdr-spinner-text {
    color: var(--text);
    font-weight: 600;
    font-size: 1rem;
    text-align: center;
    letter-spacing: 0.3px;
    animation: ccdr-pulse-text 1.5s ease-in-out infinite;
}

@keyframes ccdr-pulse-text {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.ccdr-spinner-dots {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.ccdr-spinner-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: ccdr-bounce 1.4s infinite ease-in-out both;
}

.ccdr-spinner-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.ccdr-spinner-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes ccdr-bounce {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== CONTENT LOADING ===== */
.ccdr-loading-skeleton {
    background: linear-gradient(90deg, var(--light) 25%, #f0f0f0 50%, var(--light) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.ccdr-skeleton-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

.ccdr-skeleton-line {
    height: 12px;
    border-radius: 4px;
    margin-bottom: 8px;
    width: 100%;
}

.ccdr-skeleton-line.short {
    width: 70%;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .ccdr-container {
        padding: 20px 16px;
        border-radius: var(--radius-lg);
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .ccdr-meetings-list {
        grid-template-columns: 1fr;
    }
    
    .ccdr-details-grid {
        grid-template-columns: 1fr;
    }
    
    .ccdr-modal-content {
        max-width: 95vw;
        padding: 20px;
    }
    
    .ccdr-meeting-card-actions {
        flex-direction: column;
    }
    
    .ccdr-meeting-card-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .ccdr-form-actions {
        flex-direction: column-reverse;
    }
    
    .ccdr-form-actions .btn {
        width: 100%;
    }
}
