/* Apple Clean Style - Score App (based on Collection App design) */

:root {
    --primary-color: #4CAF50;
    --primary-hover: #45a049;
    --primary-light: #e8f5e9;
    --secondary-color: #424242;
    --background: #ffffff;
    --surface: #f5f5f5;
    --border: #e0e0e0;
    --text-primary: #212121;
    --text-secondary: #616161;
    --error: #d32f2f;
    --warning: #f57c00;
    --success: #4CAF50;
    --info: #1976d2;

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --border-radius: 8px;
    --box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* Header */
.header {
    background-color: var(--background);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    min-height: 72px;
    will-change: auto;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.logo-image {
    height: 40px;
    width: auto;
    object-fit: contain;
    margin-bottom: 4px;
}

.logo-text {
    font-size: 13px;
    font-weight: 400;
    color: #666;
    text-align: center;
    line-height: 1.2;
}

/* Navigation */
.nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-link {
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: color 0.2s ease, border-color 0.2s ease;
    display: inline-block;
    position: relative;
    border-bottom: 2px solid transparent;
    font-weight: 500;
}

.nav-link:hover {
    color: var(--text-primary);
    text-decoration: none;
}

.nav-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* User menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-email {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

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

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

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

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

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

.btn-danger:hover {
    background-color: #b71c1c;
}

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

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

/* Cards */
.card {
    background-color: var(--background);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 24px;
    margin-bottom: 20px;
}

.card-header {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: var(--font-family);
    transition: var(--transition);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--background);
}

.table thead {
    background-color: var(--surface);
}

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

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

.table td {
    font-size: 14px;
    font-weight: 400;
}

.table tbody tr:hover {
    background-color: var(--surface);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background-color: #c8e6c9;
    color: #2e7d32;
}

.badge-danger {
    background-color: #ffcdd2;
    color: #c62828;
}

.badge-warning {
    background-color: #ffe0b2;
    color: #e65100;
}

.badge-info {
    background-color: #bbdefb;
    color: #1565c0;
}

/* Alerts - Toast Style */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert {
    padding: 14px 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    max-width: 450px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.alert.fade-out {
    animation: slideOut 0.3s ease-in forwards;
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

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

.alert-error {
    background-color: #ffebee;
    color: var(--error);
    border-left: 4px solid var(--error);
}

.alert-warning {
    background-color: #fff3e0;
    color: var(--warning);
    border-left: 4px solid var(--warning);
}

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

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 10001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--background);
    border-radius: var(--border-radius);
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    background-color: var(--surface);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Loader */
.loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

.loader.show {
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

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

/* Login page logo */
.login-logo-image {
    height: 80px;
    width: auto;
    object-fit: contain;
}

/* Main content */
.main-content {
    padding: 32px 0;
    flex: 1;
}

/* Footer */
.footer {
    background-color: #424242;
    border-top: 1px solid #333;
    padding: 20px 0;
    text-align: center;
    color: #b0b0b0;
    font-size: 13px;
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-success { color: #2e7d32; font-weight: 600; }
.text-danger { color: #c62828; font-weight: 600; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

/* ============================================ */
/* Score App Specific Styles                    */
/* ============================================ */

/* KPI Cards */
.kpi-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--background);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--box-shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.kpi-card.warning {
    border-left: 4px solid var(--warning);
}

.kpi-content h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
    font-weight: 500;
}

.kpi-content p {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.kpi-icon {
    font-size: 2.5rem;
    opacity: 0.7;
}

.kpi-icon.blue { color: #3b82f6; }
.kpi-icon.green { color: #10b981; }
.kpi-icon.red { color: #ef4444; }
.kpi-icon.orange { color: #ff8c00; }

/* Filter Tabs */
.filter-tabs {
    background: var(--background);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--box-shadow);
}

.tab-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--border);
    background: var(--background);
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    font-size: 13px;
}

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

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

/* Search */
.search-section {
    background: var(--background);
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--box-shadow);
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-box input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: var(--font-family);
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Add EDRPOU Section */
.add-edrpou-section {
    background: var(--background);
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--box-shadow);
}

.add-form {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.add-form input {
    flex: 1;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: var(--font-family);
    transition: var(--transition);
}

.add-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.btn-add {
    padding: 0.6rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-add:hover {
    background: var(--primary-hover);
}

/* Data Table */
.table-section {
    background: var(--background);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 1.5rem;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1400px;
    table-layout: fixed;
}

.custom-table thead {
    background: var(--surface);
    border-bottom: 2px solid var(--border);
}

.custom-table thead th {
    padding: 0.75rem 0.5rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    text-transform: capitalize;
}

.custom-table tbody tr {
    border-bottom: 1px solid #f1f3f5;
    transition: background-color 0.15s;
}

.custom-table tbody tr:hover {
    background-color: var(--surface);
}

.custom-table tbody tr.red-flag-row {
    background-color: #fff5f5;
    border-left: 3px solid #ef4444;
}

.custom-table tbody tr.red-flag-row:hover {
    background-color: #fee2e2;
}

.custom-table tbody td {
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    vertical-align: top;
}

/* Column widths */
.custom-table th:nth-child(1),
.custom-table td:nth-child(1) { width: 40px; text-align: center; }
.custom-table th:nth-child(2),
.custom-table td:nth-child(2) { width: 80px; }
.custom-table th:nth-child(3),
.custom-table td:nth-child(3) { width: 220px; white-space: normal; word-wrap: break-word; }
.custom-table th:nth-child(4),
.custom-table td:nth-child(4) { width: 90px; white-space: nowrap; }
.custom-table th:nth-child(5),
.custom-table td:nth-child(5) { width: 70px; }
.custom-table th:nth-child(6),
.custom-table td:nth-child(6) { width: 70px; }
.custom-table th:nth-child(7),
.custom-table td:nth-child(7) { width: 70px; }
.custom-table th:nth-child(8),
.custom-table td:nth-child(8) { width: 70px; }
.custom-table th:nth-child(9),
.custom-table td:nth-child(9) { width: 90px; }
.custom-table th:nth-child(10),
.custom-table td:nth-child(10) { width: 100px; }
.custom-table th:nth-child(11),
.custom-table td:nth-child(11) { width: 110px; white-space: nowrap; }
.custom-table th:nth-child(12),
.custom-table td:nth-child(12) { width: 110px; white-space: nowrap; }
.custom-table th:nth-child(13),
.custom-table td:nth-child(13) { width: 50px; text-align: center; }

/* Score Badge */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    min-width: 50px;
}

.score-excellent { background: #d1f4e0; color: #10b981; }
.score-good { background: #dbeafe; color: #3b82f6; }
.score-fair { background: #fef3c7; color: #f59e0b; }
.score-poor { background: #fee2e2; color: #ef4444; }

/* Flags */
.flag-item {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
}

.flag-danger { background: #fee2e2; color: #ef4444; }
.flag-warning { background: #fef3c7; color: #f59e0b; }

/* Action Menu */
.action-menu {
    position: relative;
    display: inline-block;
}

.btn-menu {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: color 0.2s;
}

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

.menu-dropdown {
    display: none;
    position: fixed;
    background: var(--background);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    z-index: 10000;
    overflow: hidden;
    border: 1px solid var(--border);
}

.menu-dropdown.show,
.menu-dropdown.show-up {
    display: block;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.2s;
    font-size: 0.875rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: var(--surface);
    text-decoration: none;
    color: var(--primary-color);
}

.menu-item i {
    width: 16px;
    text-align: center;
    color: var(--text-secondary);
}

.menu-item:hover i {
    color: var(--primary-color);
}

/* Log Modal */
.modal-log-container {
    max-height: 400px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Fira Code', monospace;
    background-color: var(--surface);
    padding: 12px;
    border-radius: var(--border-radius);
    margin-top: 8px;
    font-size: 13px;
}

.log-entry {
    margin-bottom: 4px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-success { color: var(--success); }
.log-error { color: var(--error); }
.log-info { color: var(--info); }

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

/* Tooltip for warning flags */
.warning-badge {
    position: relative;
    display: inline-block;
    cursor: help;
}

.warning-tooltip {
    visibility: hidden;
    position: absolute;
    z-index: 1001;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    text-align: left;
    padding: 0.75rem;
    border-radius: 6px;
    min-width: 250px;
    max-width: 350px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85rem;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.warning-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.warning-badge:hover .warning-tooltip {
    visibility: visible;
    opacity: 1;
}

.warning-tooltip-item {
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.warning-tooltip-item:last-child {
    border-bottom: none;
}

/* Status indicator for partial update */
.status-updating {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    background: #e3f2fd;
    color: #1976d2;
}

.status-updating .spinner-sm {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(25, 118, 210, 0.3);
    border-top-color: #1976d2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Responsive */
@media (max-width: 768px) {
    .kpi-cards {
        grid-template-columns: 1fr;
    }
    .custom-table {
        font-size: 0.8rem;
    }
}
