/* Invoice Manager Styles */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #10b981;
    --success-hover: #059669;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --warning-color: #f59e0b;
    --secondary-color: #6b7280;
    --secondary-hover: #4b5563;
    --border-color: #e5e7eb;
    --bg-light: #f9fafb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Container */
.invoice-manager-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Header */
.invoice-header {
    margin-bottom: 30px;
    text-align: center;
}

.invoice-header h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.invoice-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0;
}

/* Section */
.invoice-section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
}

.section-header {
    margin-bottom: 24px;
}

.section-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.section-header p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: var(--bg-light);
}

.upload-area.drag-over {
    border-color: var(--primary-color);
    background-color: #eff6ff;
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 16px;
}

.upload-area h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.upload-area p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 8px 0;
}

.upload-note {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Progress Bar */
.upload-progress {
    text-align: center;
    padding: 24px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--bg-light);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #3b82f6);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* PDF Pages Grid */
.pdf-pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.pdf-page-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    transition: all 0.3s ease;
}

.pdf-page-item:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.page-number {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
    background: #eff6ff;
    padding: 4px 12px;
    border-radius: 12px;
    display: inline-block;
    margin-bottom: 12px;
}

.pdf-preview {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 12px;
    background: var(--bg-light);
    overflow: hidden;
}

.pdf-preview canvas {
    width: 100%;
    height: auto;
    display: block;
}

.pdf-preview-placeholder {
    width: 100%;
    aspect-ratio: 1 / 1.414;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
}

.company-input-group {
    margin-bottom: 0;
}

.company-input-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.company-input-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.company-input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background-color: var(--success-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: var(--danger-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--secondary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

/* Table */
.table-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.invoice-table thead {
    background-color: var(--bg-light);
}

.invoice-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

.invoice-table td {
    padding: 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.invoice-table tbody tr:hover {
    background-color: var(--bg-light);
}

.invoice-table tbody tr:last-child td {
    border-bottom: none;
}

.table-actions {
    display: flex;
    gap: 8px;
}

.loading-row {
    text-align: center;
    padding: 48px 16px !important;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: 48px 16px !important;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    padding: 32px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-icon.success {
    background-color: #d1fae5;
    color: var(--success-color);
}

.modal-icon.warning {
    background-color: #fef3c7;
    color: var(--warning-color);
}

.modal-content h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.modal-content p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 24px 0;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Error Message */
.invoice-error {
    background-color: #fee2e2;
    color: #991b1b;
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid var(--danger-color);
    font-size: 14px;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
    .invoice-manager-container {
        padding: 16px;
    }

    .invoice-section {
        padding: 20px;
    }

    .invoice-header h2 {
        font-size: 24px;
    }

    .upload-area {
        padding: 32px 16px;
    }

    .pdf-pages-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .table-container {
        border-radius: 0;
        margin: 0 -20px;
    }

    .invoice-table th,
    .invoice-table td {
        padding: 12px;
        font-size: 12px;
    }

    .table-actions {
        flex-direction: column;
    }

    .table-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .modal-content {
        padding: 24px;
        width: 95%;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .invoice-header h2 {
        font-size: 20px;
    }

    .invoice-subtitle {
        font-size: 14px;
    }

    .section-header h3 {
        font-size: 18px;
    }

    .upload-area h3 {
        font-size: 18px;
    }

    /* Make table responsive with horizontal scroll */
    .invoice-table {
        min-width: 600px;
    }
}

/* Loading state for buttons */
.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}