/* Reset y base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #1B5A8C 0%, #3B7CB8 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

/* Layout */
.screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Cards */
.card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Typography */
h1 {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #1B5A8C, #3B7CB8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: #34495e;
}

/* Header */
.dashboard-header {
    margin-bottom: 30px;
}

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

.header-content h1 {
    background: none;
    -webkit-text-fill-color: white;
    color: white;
}

/* Forms */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #2c3e50;
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: #fff;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
    outline: none;
    border-color: #1B5A8C;
    box-shadow: 0 0 0 3px rgba(27, 90, 140, 0.1);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, #1B5A8C, #3B7CB8);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(27, 90, 140, 0.3);
}

.btn-secondary {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #e9ecef;
}

.btn-secondary:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

.btn-large {
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    margin-top: 10px;
}

/* Batch Status */
.batch-info {
    margin-bottom: 25px;
}

.batch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.batch-id {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    color: #495057;
}

.batch-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.batch-status.starting { background: #fff3cd; color: #856404; }
.batch-status.running { background: #d1ecf1; color: #0c5460; }
.batch-status.completed { background: #d4edda; color: #155724; }
.batch-status.failed { background: #f8d7da; color: #721c24; }

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #1B5A8C, #3B7CB8);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #6c757d;
}

.progress-percentage {
    font-weight: 600;
    color: #495057;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.stat {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 5px;
    text-transform: uppercase;
    font-weight: 500;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #495057;
}

.stat-value.success { color: #28a745; }
.stat-value.error { color: #dc3545; }

/* Company Results */
.company-list {
    margin-top: 25px;
}

.company-results {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #f8f9fa;
}

.company-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
}

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

.company-name {
    font-weight: 500;
    color: #495057;
}

.company-status {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

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

.company-status.error {
    background: #f8d7da;
    color: #721c24;
}

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

/* Batch Actions */
.batch-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 25px;
}


.empty-state {
    text-align: center;
    color: #6c757d;
    padding: 40px;
    font-style: italic;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1B5A8C;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    color: white;
    font-size: 16px;
    font-weight: 500;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
}

.toast {
    background: #fff;
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-left: 4px solid #1B5A8C;
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

.toast.success { border-left-color: #28a745; }
.toast.error { border-left-color: #dc3545; }
.toast.warning { border-left-color: #ffc107; }

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

/* Error Messages */
.error-message {
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 12px;
    border-radius: 6px;
    margin-top: 15px;
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .header-content h1 {
        font-size: 2rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .batch-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .batch-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .company-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* Excel Loading & Companies Table */
.excel-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.table-stats {
    display: flex;
    gap: 20px;
    align-items: center;
}

.table-stats span {
    font-size: 14px;
    color: #6c757d;
}

.table-actions {
    display: flex;
    gap: 10px;
}

.table-container {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #fff;
}

#companies-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

#companies-table th,
#companies-table td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
    white-space: nowrap;
}

#companies-table td:nth-child(3) {
    white-space: normal;
    max-width: 200px;
}

#companies-table th {
    background: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
}

/* Columna Acciones específica - Por posición real */
#companies-table thead th:nth-child(8),
#companies-table tbody td:nth-child(8) {
    min-width: 120px !important;
    text-align: center !important;
    white-space: nowrap !important;
    width: 120px !important;
}

#companies-table tbody tr:hover {
    background: #f8f9fa;
}

#companies-table tbody tr.processing {
    background: #d1ecf1;
    animation: pulse 1.5s infinite;
}

#companies-table tbody tr.completed {
    background: #d4edda;
}

#companies-table tbody tr.failed {
    background: #f8d7da;
}

.company-status {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.company-status.pending {
    background: #f8f9fa;
    color: #6c757d;
}

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

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

.company-status.failed {
    background: #f8d7da;
    color: #721c24;
}

.company-actions {
    display: flex;
    gap: 5px;
    justify-content: center;
    width: 100%;
}

.btn-mini {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap !important;
    min-width: 70px !important;
    flex-shrink: 0;
}

/* Solución específica para botones en company-actions */
.company-actions button {
    white-space: nowrap !important;
    display: inline-block !important;
    min-width: 80px !important;
}

/* Mayor especificidad para btn-mini */
.btn.btn-mini.btn-secondary {
    white-space: nowrap !important;
    display: inline-block !important;
    min-width: 80px !important;
}

.processing-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #1B5A8C;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 8px;
}

.progress-info {
    margin-bottom: 20px;
}

.processing-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 25px;
}

/* Animations */
@keyframes pulse {
    0% {
        background-color: #d1ecf1;
    }
    50% {
        background-color: #bee5eb;
    }
    100% {
        background-color: #d1ecf1;
    }
}

/* Checkbox styling */
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Credentials status styles */
.credentials-status {
    font-size: 1.2rem;
    padding: 4px;
    border-radius: 4px;
    cursor: help;
    display: inline-block;
}

.credentials-status.validating {
    animation: pulse 1.5s ease-in-out infinite;
}

.credentials-status.valid {
    color: #28a745;
}

.credentials-status.invalid {
    color: #dc3545;
}

.credentials-status.error {
    color: #ffc107;
}

/* Style disabled rows */
#companies-table tbody tr:has(input[type="checkbox"]:disabled) {
    opacity: 0.7;
}

/* Responsive adjustments for new components */
@media (max-width: 768px) {
    .table-controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .table-stats {
        flex-direction: column;
        gap: 5px;
        align-items: flex-start;
    }
    
    .excel-actions {
        flex-direction: column;
    }
    
    .excel-actions .btn {
        width: 100%;
    }
    
    .table-container {
        font-size: 12px;
    }
    
    #companies-table th,
    #companies-table td {
        padding: 8px 4px;
    }
    
    .company-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .card {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .toast-container {
        right: 10px;
        left: 10px;
    }
    
    .toast {
        max-width: none;
    }
    
    .table-container {
        max-height: 300px;
    }
    
    #companies-table {
        font-size: 11px;
    }
}

/* Process Log Section */
.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.log-controls {
    display: flex;
    gap: 10px;
}

.completion-summary {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid #1B5A8C;
}

.completion-summary h3 {
    color: #1B5A8C;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.summary-stat {
    text-align: center;
    padding: 10px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.summary-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.summary-stat-value.success { color: #28a745; }
.summary-stat-value.error { color: #dc3545; }
.summary-stat-value.total { color: #6c757d; }

.summary-stat-label {
    font-size: 0.875rem;
    color: #6c757d;
}

.summary-lists {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 15px;
}

.summary-list h4 {
    font-size: 1rem;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 2px solid #e9ecef;
}

.summary-list.successful h4 { border-bottom-color: #28a745; }
.summary-list.failed h4 { border-bottom-color: #dc3545; }

.summary-items {
    max-height: 200px;
    overflow-y: auto;
}

.summary-item {
    padding: 8px 0;
    border-bottom: 1px solid #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.summary-item-name {
    font-weight: 500;
    color: #333;
}

.summary-item-code {
    font-size: 0.875rem;
    color: #6c757d;
    font-family: monospace;
}

.summary-item-duration {
    font-size: 0.875rem;
    color: #6c757d;
}

.error-details {
    font-size: 0.875rem;
    color: #dc3545;
    margin-top: 4px;
    padding: 4px 8px;
    background: #f8d7da;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
}

#process-log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

#process-log-table th,
#process-log-table td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

#process-log-table th {
    background: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

#process-log-table tbody tr:hover {
    background: #f8f9fa;
}

#process-log-table tbody tr.completed {
    background: rgba(212, 237, 218, 0.3);
}

#process-log-table tbody tr.failed {
    background: rgba(248, 215, 218, 0.3);
}

.log-status {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

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

.log-status.failed {
    background: #f8d7da;
    color: #721c24;
}

.log-duration {
    font-family: monospace;
    color: #6c757d;
}

.log-error {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
    color: #dc3545;
}

.log-time {
    font-family: monospace;
    color: #6c757d;
    font-size: 0.875rem;
}

/* Responsive adjustments for log section */
@media (max-width: 768px) {
    .log-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .summary-lists {
        grid-template-columns: 1fr;
    }
    
    .summary-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .log-error {
        max-width: 150px;
    }
}

@media (max-width: 480px) {
    .summary-stats {
        grid-template-columns: 1fr;
    }
    
    .log-controls {
        flex-direction: column;
        width: 100%;
    }
    
    .log-controls .btn {
        width: 100%;
    }
}