/* GGV Oppgjørsgenerator Styles */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #16a34a;
    --warning-color: #eab308;
    --error-color: #dc2626;
    --background-color: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Upload Section */
.upload-section {
    margin-bottom: 2rem;
}

.upload-area {
    background: var(--card-background);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-subtext {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.upload-button {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.upload-button:hover {
    background: var(--primary-hover);
}

.file-name {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Status Section */
.status-section {
    background: var(--card-background);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.status-content {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.status-text {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

/* Error Section */
.error-section {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.error-content {
    text-align: center;
}

.error-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--error-color);
    color: white;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.error-text {
    color: var(--error-color);
    margin-bottom: 1rem;
}

.retry-button {
    background: var(--error-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.retry-button:hover {
    opacity: 0.9;
}

/* Results Section */
.results-section {
    background: var(--card-background);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.results-actions {
    display: flex;
    gap: 0.75rem;
}

.action-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.625rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 0.875rem;
}

.action-button:hover {
    background: var(--primary-hover);
}

.action-button.secondary {
    background: var(--secondary-color);
}

.action-button.secondary:hover {
    background: #475569;
}

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

.summary-card {
    background: var(--background-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.summary-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.summary-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Validation Message */
.validation-message {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.validation-message.success {
    background: #f0fdf4;
    color: var(--success-color);
    border: 1px solid #bbf7d0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.validation-message.success::before {
    content: "✓";
    font-weight: bold;
}

.validation-message.warning {
    background: #fefce8;
    color: #a16207;
    border: 1px solid #fef08a;
}

.validation-message.error {
    background: #fef2f2;
    color: var(--error-color);
    border: 1px solid #fecaca;
}

.validation-message:empty {
    display: none;
}

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

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.results-table th,
.results-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.results-table th {
    background: var(--background-color);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.results-table tbody tr:nth-child(odd) {
    background: var(--background-color);
}

.results-table tbody tr:hover {
    background: #e2e8f0;
}

.results-table thead {
    position: sticky;
    top: 0;
}

.results-table td:nth-child(2),
.results-table td:nth-child(3),
.results-table td:nth-child(4) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.results-table th:nth-child(2),
.results-table th:nth-child(3),
.results-table th:nth-child(4) {
    text-align: right;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Verification Section */
.verification-section {
    background: var(--background-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.verification-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.verification-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.verification-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.verification-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.verification-value {
    font-size: 1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.verification-value.match {
    color: var(--success-color);
}

.verification-value.mismatch {
    color: var(--error-color);
}

/* Table Controls */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    flex: 1;
    max-width: 300px;
}

.search-box svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.875rem;
    color: var(--text-primary);
    width: 100%;
}

.search-box input::placeholder {
    color: var(--text-secondary);
}

.sort-info {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Sortable Headers */
.results-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.results-table th.sortable:hover {
    background: #e2e8f0;
}

.sort-icon {
    display: inline-block;
    margin-left: 0.25rem;
    opacity: 0.3;
}

.sort-icon::after {
    content: "↕";
}

.results-table th.sortable.asc .sort-icon::after {
    content: "↑";
    opacity: 1;
}

.results-table th.sortable.desc .sort-icon::after {
    content: "↓";
    opacity: 1;
}

.results-table th.sortable.asc .sort-icon,
.results-table th.sortable.desc .sort-icon {
    opacity: 1;
}

/* Highlight search matches */
.results-table tbody tr.hidden {
    display: none;
}

.results-table tbody tr.highlight td:first-child {
    background: #fef3c7;
}

/* Zero amount rows (not in PDF) */
.results-table tbody tr.zero-amount {
    opacity: 0.5;
}

.results-table tbody tr.zero-amount td {
    color: var(--text-secondary);
}

/* No results message */
.no-results {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-arrow {
    transition: transform 0.2s ease;
}

.dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.5rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 240px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s ease;
}

.dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 8px 8px;
}

.dropdown-item:hover {
    background: #f1f5f9;
}

.dropdown-item-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.dropdown-item-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.125rem;
}

/* Copy Notification */
.copy-notification {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
}

.copy-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Header with Settings */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.header-text {
    text-align: center;
    flex: 1;
}

.settings-button {
    position: relative;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.settings-button:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.settings-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--primary-color);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* New Organizations Alert */
.new-orgs-alert {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.new-orgs-content {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.new-orgs-icon {
    background: #f59e0b;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.new-orgs-text {
    flex: 1;
}

.new-orgs-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.new-org-tag {
    background: white;
    border: 1px solid #f59e0b;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.new-orgs-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.new-orgs-add-btn,
.new-orgs-report-btn {
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    white-space: nowrap;
}

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

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

.new-orgs-report-btn {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.new-orgs-report-btn:hover {
    background: var(--background-color);
}

.new-orgs-dismiss {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
}

/* Modal */
.modal {
    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: 3000;
    padding: 1rem;
}

.modal-content {
    background: var(--card-background);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.modal-section {
    margin-bottom: 1.5rem;
}

.modal-section h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.section-help {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.modal-section textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 0.75rem;
}

.modal-section textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.section-actions {
    display: flex;
    gap: 0.5rem;
}

.modal-button {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

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

.modal-button.primary:hover {
    background: var(--primary-hover);
}

.modal-button.secondary {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

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

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

.modal-button.danger:hover {
    background: #b91c1c;
}

.modal-button.small {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* Master List Container */
.master-list-container {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem;
}

.empty-list-message {
    color: var(--text-secondary);
    text-align: center;
    padding: 1rem;
    font-style: italic;
}

.master-list-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 4px;
    gap: 0.5rem;
}

.master-list-item:hover {
    background: var(--background-color);
}

.master-list-number {
    color: var(--text-secondary);
    font-size: 0.8rem;
    min-width: 2rem;
}

.master-list-name {
    flex: 1;
    font-size: 0.9rem;
}

.master-list-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s;
}

.master-list-item:hover .master-list-remove {
    opacity: 1;
}

.master-list-remove:hover {
    color: var(--error-color);
}

/* Footer link */
.footer-link {
    margin-top: 0.5rem;
}

.footer-link a {
    color: var(--text-secondary);
    text-decoration: underline;
    font-size: 0.85rem;
}

.footer-link a:hover {
    color: var(--primary-color);
}

/* Org list modal */
.org-search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
}

.org-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.org-list-container {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
}

.org-list-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

.org-list-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.15s;
}

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

.org-list-item:hover {
    background-color: #fef3c7;
}

.org-remove-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.15s;
}

.org-list-item:hover .org-remove-hint {
    opacity: 1;
}

.modal-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.reset-list-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: underline;
}

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

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .results-header {
        flex-direction: column;
        align-items: stretch;
    }

    .results-actions {
        justify-content: stretch;
        flex-wrap: wrap;
    }

    .action-button {
        flex: 1;
        justify-content: center;
    }

    .dropdown {
        width: 100%;
    }

    .dropdown-toggle {
        width: 100%;
        justify-content: center;
    }

    .dropdown-menu {
        left: 0;
        right: 0;
        min-width: 100%;
    }
}
