/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
    font-size: 16px;
}

/* Container and Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Section Styles */
.form-section,
.table-section {
    background: white;
    padding: 30px;
    margin-bottom: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.form-section h2,
.table-section h2 {
    font-size: 1.8rem;
    margin-bottom: 25px;
    color: #2c3e50;
    border-bottom: 3px solid #3498db;
    padding-bottom: 10px;
}

/* Form Styles */
.client-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    align-items: start;
}

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

.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #34495e;
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 15px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Error Message Styles */
.error-message {
    color: #e74c3c;
    font-size: 0.875rem;
    margin-top: 5px;
    min-height: 20px;
    font-weight: 500;
}

/* Button Styles */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-add {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    grid-column: 1 / -1;
    justify-self: start;
    min-width: 150px;
}

.btn-add:hover {
    background: linear-gradient(135deg, #229954, #27ae60);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.btn-delete {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-delete:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

/* Table Styles */
.table-container {
    overflow-x: auto;
}

.clients-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.clients-table th {
    background: linear-gradient(135deg, #34495e, #2c3e50);
    color: white;
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.clients-table td {
    padding: 15px 12px;
    border-bottom: 1px solid #ecf0f1;
    vertical-align: middle;
}

.clients-table tbody tr:hover {
    background-color: #f8f9fa;
}

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

/* Status Badge Styles */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background-color: #d4edda;
    color: #155724;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-completed {
    background-color: #d1ecf1;
    color: #0c5460;
}

.status-on-hold {
    background-color: #f8d7da;
    color: #721c24;
}

.status-cancelled {
    background-color: #e2e3e5;
    color: #383d41;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #7f8c8d;
}

.empty-state p {
    font-size: 1.1rem;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 2rem;
    }

    header p {
        font-size: 1rem;
    }

    .form-section,
    .table-section {
        padding: 20px;
    }

    .client-form {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .clients-table {
        font-size: 0.9rem;
    }

    .clients-table th,
    .clients-table td {
        padding: 10px 8px;
    }

    /* Stack table cells on very small screens */
    @media (max-width: 600px) {
        .clients-table,
        .clients-table thead,
        .clients-table tbody,
        .clients-table th,
        .clients-table td,
        .clients-table tr {
            display: block;
        }

        .clients-table thead tr {
            position: absolute;
            top: -9999px;
            left: -9999px;
        }

        .clients-table tr {
            border: 1px solid #ccc;
            margin-bottom: 15px;
            padding: 15px;
            border-radius: 8px;
            background: white;
        }

        .clients-table td {
            border: none;
            position: relative;
            padding: 8px 0 8px 40%;
            text-align: left;
        }

        .clients-table td:before {
            content: attr(data-label) ": ";
            position: absolute;
            left: 6px;
            width: 35%;
            text-align: left;
            font-weight: 600;
            color: #34495e;
        }

        .clients-table td:last-child {
            text-align: center;
            padding: 15px 0 0 0;
        }

        .clients-table td:last-child:before {
            display: none;
        }
    }
}

@media (max-width: 480px) {
    header {
        padding: 20px 0;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .form-section,
    .table-section {
        padding: 15px;
    }

    .btn-add {
        width: 100%;
        justify-self: stretch;
    }
}

/* Loading and Animation States */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

/* Focus Management */
.form-group input:invalid {
    border-color: #e74c3c;
}

.form-group input:valid {
    border-color: #27ae60;
}

/* Progress Slider Styles */
.progress-slider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #e1e8ed;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
    margin-bottom: 10px;
}

.progress-slider::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.progress-slider::-webkit-slider-thumb:hover {
    background: #2980b9;
    transform: scale(1.1);
}

.progress-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.progress-display {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#progressValue {
    font-weight: 600;
    color: #3498db;
    font-size: 1.1rem;
}

.progress-display small {
    color: #7f8c8d;
    font-size: 0.85rem;
}

/* Progress Bar in Table */
.progress-bar-container {
    width: 100%;
    background-color: #e1e8ed;
    border-radius: 10px;
    overflow: hidden;
    height: 20px;
    position: relative;
    margin: 2px 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #27ae60, #2ecc71);
    border-radius: 10px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    min-width: fit-content;
}

/* Deadline Status Styles */
.deadline-status {
    font-size: 0.85rem;
    font-weight: 500;
}

.deadline-overdue {
    color: #e74c3c;
    font-weight: 600;
}

.deadline-due-soon {
    color: #f39c12;
    font-weight: 600;
}

.deadline-upcoming {
    color: #3498db;
}

.deadline-no-date {
    color: #95a5a6;
    font-style: italic;
}

/* Fee Display Styles */
.fee-amount {
    font-weight: 600;
    color: #27ae60;
    font-size: 0.9rem;
}

.fee-not-set {
    color: #95a5a6;
    font-style: italic;
    font-size: 0.85rem;
}

/* Reports Section Styles */
.reports-section {
    background: white;
    padding: 30px;
    margin-bottom: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.reports-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.reports-header h2 {
    font-size: 1.8rem;
    margin: 0;
    color: #2c3e50;
    border-bottom: 3px solid #3498db;
    padding-bottom: 10px;
}

.report-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.report-select {
    padding: 10px 15px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.report-select:focus {
    outline: none;
    border-color: #3498db;
}

.btn-report {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 10px 20px;
    font-size: 0.9rem;
}

.btn-report:hover {
    background: linear-gradient(135deg, #2980b9, #2471a3);
    transform: translateY(-1px);
}

.btn-export {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    padding: 10px 20px;
    font-size: 0.9rem;
}

.btn-export:hover {
    background: linear-gradient(135deg, #e67e22, #d68910);
    transform: translateY(-1px);
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.summary-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 25px;
    border-radius: 12px;
    color: white;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

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

.card-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

.card-content h3 {
    font-size: 2rem;
    margin: 0 0 5px 0;
    font-weight: 700;
}

.card-content p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.95rem;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.chart-container {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.chart-container h4 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 1.1rem;
    text-align: center;
    font-weight: 600;
}

.chart-container canvas {
    max-height: 300px;
}

/* Report Tables */
.report-tables {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
}

.report-table-container {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.report-table-container h4 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 1.1rem;
    font-weight: 600;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.report-table th {
    background: #34495e;
    color: white;
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
}

.report-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #ecf0f1;
    font-size: 0.9rem;
}

.report-table tbody tr:hover {
    background-color: #f8f9fa;
}

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

/* Source Input Toggle */
#customSource {
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    padding: 12px 15px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

#customSource:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Mobile Responsive for Reports */
@media (max-width: 768px) {
    .reports-header {
        flex-direction: column;
        align-items: stretch;
    }

    .report-controls {
        justify-content: center;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .report-tables {
        grid-template-columns: 1fr;
    }

    .chart-container,
    .report-table-container {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .report-controls {
        flex-direction: column;
        width: 100%;
    }

    .report-select,
    .btn-report,
    .btn-export {
        width: 100%;
    }

    .summary-card {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .card-icon {
        font-size: 2rem;
    }

    .card-content h3 {
        font-size: 1.8rem;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
