/* ==========================================
   HCC - Sistema de Importação de Honorários
   Design Clean & Professional
   ========================================== */

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

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    --green-50: #f0fdf4;
    --green-500: #22c55e;
    --green-600: #16a34a;
    --green-700: #15803d;
    
    --red-50: #fef2f2;
    --red-500: #ef4444;
    --red-600: #dc2626;
    --red-700: #b91c1c;
    
    --amber-50: #fffbeb;
    --amber-500: #f59e0b;
    --amber-600: #d97706;
    
    --white: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 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);
    
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    
    --transition: 150ms ease;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Utilities */
.hidden { display: none !important; }
.text-success { color: var(--green-600); }
.text-error { color: var(--red-600); }

/* ==========================================
   Login Screen
   ========================================== */

.screen {
    min-height: 100vh;
}

#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    padding: 24px;
}

.login-container {
    background: var(--white);
    padding: 48px 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--gray-200);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo img {
    max-width: 200px;
    height: auto;
}

.login-container h2 {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--gray-500);
    margin-bottom: 32px;
    text-align: center;
    letter-spacing: -0.01em;
}

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

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input::placeholder {
    color: var(--gray-400);
}

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

.form-group input:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
    color: var(--gray-500);
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    width: 100%;
}

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

.btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-primary:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

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

.btn-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color var(--transition);
}

.btn-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--gray-500);
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--gray-100);
    color: var(--red-600);
}

.btn-large {
    padding: 14px 24px;
    font-size: 1rem;
}

.error-message {
    color: var(--red-600);
    font-size: 0.875rem;
    margin-top: 20px;
    text-align: center;
    padding: 12px;
    background: var(--red-50);
    border-radius: var(--radius);
}

/* ==========================================
   Header
   ========================================== */

header {
    background: var(--white);
    padding: 0 32px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-logo img {
    height: 36px;
    width: auto;
}

.header-title h1 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    letter-spacing: -0.02em;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-user span {
    font-size: 0.875rem;
    color: var(--gray-600);
}

/* ==========================================
   Main Content
   ========================================== */

main {
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
}

.content-wrapper {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

/* Panels */
.panel {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

.panel h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-100);
    letter-spacing: -0.01em;
}

.config-panel { grid-column: 1; grid-row: 1; }
.upload-panel { grid-column: 2; grid-row: 1; }
.queue-panel { grid-column: 1; grid-row: 2; }
.history-panel { grid-column: 2; grid-row: 2; }

.config-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

/* Input with validation */
.input-with-validation {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-validation input {
    flex: 1;
    padding-right: 40px;
}

.validation-status {
    position: absolute;
    right: 12px;
    font-size: 1rem;
    font-weight: 600;
}

.validation-status.valid::after {
    content: '✓';
    color: var(--green-500);
}

.validation-status.invalid::after {
    content: '✕';
    color: var(--red-500);
}

.validation-status.loading::after {
    content: '...';
    color: var(--amber-500);
}

.field-description {
    font-size: 0.8125rem;
    color: var(--green-600);
    margin-top: 6px;
    min-height: 20px;
}

.field-description.error {
    color: var(--red-600);
}

.select-helper {
    margin-top: 8px;
    font-size: 0.875rem;
}

/* Upload Area */
.upload-info {
    background: var(--gray-50);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.875rem;
    color: var(--gray-600);
    border: 1px solid var(--gray-100);
}

.upload-info p {
    margin-bottom: 6px;
}

.upload-info p:last-of-type {
    margin-bottom: 0;
}

.upload-info strong {
    color: var(--gray-700);
    font-weight: 600;
}

.upload-info a {
    display: inline-block;
    margin-top: 12px;
}

.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 20px;
    background: var(--white);
}

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

.upload-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.7;
}

.upload-area p {
    color: var(--gray-500);
    font-size: 0.9375rem;
}

.file-preview {
    background: var(--primary-light);
    padding: 14px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-icon {
    font-size: 24px;
}

#file-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.9375rem;
    color: var(--gray-800);
}

/* Queue Section */
.queue-status {
    display: flex;
    gap: 32px;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-100);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-label {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.status-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
}

.current-job {
    padding: 20px;
    background: var(--primary-light);
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
}

.current-job h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 12px;
}

.job-info {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 16px;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(37, 99, 235, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

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

.progress-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    min-width: 48px;
    text-align: right;
}

.job-details {
    display: flex;
    gap: 20px;
    font-size: 0.8125rem;
    color: var(--gray-600);
}

.job-details strong {
    font-weight: 600;
}

/* History Section */
.history-list {
    max-height: 280px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.history-item {
    padding: 14px 16px;
    border: 1px solid var(--gray-100);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 8px;
}

.history-item:hover {
    background: var(--gray-50);
    border-color: var(--gray-200);
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.history-file {
    font-weight: 500;
    font-size: 0.9375rem;
    color: var(--gray-800);
}

.history-status {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 99px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.history-status.completed {
    background: var(--green-50);
    color: var(--green-700);
}

.history-status.failed {
    background: var(--red-50);
    color: var(--red-700);
}

.history-status.processing {
    background: var(--amber-50);
    color: var(--amber-600);
}

.history-details {
    font-size: 0.8125rem;
    color: var(--gray-500);
    display: flex;
    gap: 16px;
}

.empty-state {
    text-align: center;
    color: var(--gray-400);
    padding: 32px;
    font-size: 0.9375rem;
}

/* ==========================================
   Modals
   ========================================== */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 200ms ease;
}

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

.modal-sm {
    max-width: 420px;
}

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-800);
    letter-spacing: -0.01em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-400);
    line-height: 1;
    padding: 4px;
    transition: color var(--transition);
}

.modal-close:hover {
    color: var(--gray-600);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

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

/* Progress Modal */
.import-progress {
    text-align: center;
    padding: 24px 0;
}

.import-progress .spinner {
    width: 52px;
    height: 52px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 24px;
}

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

.import-progress h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.import-progress p {
    font-size: 0.9375rem;
    color: var(--gray-500);
    margin-bottom: 24px;
}

.import-progress .progress-bar {
    height: 6px;
    background: var(--gray-200);
    margin-bottom: 16px;
}

.import-progress .progress-fill {
    background: var(--primary);
}

.import-progress .progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--gray-500);
}

.import-progress .progress-info strong {
    color: var(--gray-700);
}

/* Validation Errors */
.validation-errors {
    margin-top: 20px;
    padding: 16px;
    background: var(--amber-50);
    border-radius: var(--radius);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.validation-errors h4 {
    font-size: 0.875rem;
    color: var(--amber-600);
    margin-bottom: 10px;
    font-weight: 600;
}

.validation-errors ul {
    list-style: none;
    font-size: 0.8125rem;
    color: var(--gray-700);
}

.validation-errors li {
    padding: 4px 0;
    padding-left: 16px;
    position: relative;
}

.validation-errors li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--amber-500);
}

/* Result Summary */
.result-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.result-card {
    text-align: center;
    padding: 20px;
    border-radius: var(--radius);
    background: var(--gray-50);
}

.result-card.success {
    background: var(--green-50);
}

.result-card.error {
    background: var(--red-50);
}

.result-card .number {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--gray-800);
}

.result-card.success .number {
    color: var(--green-600);
}

.result-card.error .number {
    color: var(--red-600);
}

.result-card .label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.result-errors {
    max-height: 180px;
    overflow-y: auto;
}

.result-errors h4 {
    font-size: 0.875rem;
    margin-bottom: 12px;
    color: var(--red-700);
    font-weight: 600;
}

.result-errors ul {
    font-size: 0.8125rem;
    padding-left: 20px;
    color: var(--gray-600);
}

.result-errors li {
    margin-bottom: 6px;
    line-height: 1.5;
}

/* ==========================================
   Toast Notifications
   ========================================== */

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: toastIn 250ms ease;
    max-width: 360px;
    font-size: 0.9375rem;
    font-weight: 500;
}

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

.toast.success {
    background: var(--green-600);
    color: var(--white);
}

.toast.error {
    background: var(--red-600);
    color: var(--white);
}

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

.toast.warning {
    background: var(--amber-500);
    color: var(--white);
}

/* ==========================================
   Responsive Design
   ========================================== */

@media (max-width: 1024px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }
    
    .config-panel { grid-column: 1; grid-row: 1; }
    .upload-panel { grid-column: 1; grid-row: 2; }
    .queue-panel { grid-column: 1; grid-row: 3; }
    .history-panel { grid-column: 1; grid-row: 4; }
}

@media (max-width: 768px) {
    main {
        padding: 16px;
    }
    
    header {
        padding: 0 16px;
        height: 56px;
    }
    
    .header-title {
        display: none;
    }
    
    .panel {
        padding: 20px;
    }
    
    .config-grid {
        grid-template-columns: 1fr;
    }
    
    .queue-status {
        flex-direction: column;
        gap: 12px;
    }
    
    .result-summary {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 32px 24px;
    }
    
    .job-details {
        flex-direction: column;
        gap: 6px;
    }
}
