/**
 * Automation Workflow Styles
 * Styles for Ready for Deletion section, automation settings, and modals
 */

/* =====================================================
   AUTOMATION SECTION CONTAINER
   ===================================================== */

/* Outer automation panel - acts as wrapper */
#automation-panel.automation-section {
    background: transparent !important;
    border-radius: 0;
    padding: 24px 0;
    margin-bottom: 0;
    max-width: var(--container-max-width, 1200px);
    margin-left: auto;
    margin-right: auto;
    padding-left: 24px;
    padding-right: 24px;
}

/* Inner automation sections - have the dark styling */
#automation-panel > .automation-section,
#automation-panel > details.automation-section {
    background: #1e293b;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

/* Default for other contexts */
.automation-section:not(#automation-panel) {
    background: #1e293b;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.automation-section h2 {
    color: #f8fafc;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Automation Header with Run Button */
.automation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.automation-header h2 {
    margin-bottom: 0;
}

.run-automation-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-run-automation {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
}

.btn-run-automation:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.4);
}

.btn-run-automation:active {
    transform: translateY(0);
}

.btn-run-automation.disabled {
    background: #475569;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-run-automation.disabled:hover {
    transform: none;
}

.run-hint {
    font-size: 12px;
    color: #94a3b8;
}

/* Auto mode info */
.auto-mode-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #0f172a;
    padding: 10px 15px;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 13px;
}

.auto-icon {
    font-size: 20px;
}

.btn-run-manual {
    background: #334155;
    color: #e2e8f0;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 10px;
}

.btn-run-manual:hover {
    background: #475569;
}

/* Mode badges */
.status-badge.auto-mode {
    background: #1e40af;
    color: #93c5fd;
}

.status-badge.manual-mode {
    background: #065f46;
    color: #6ee7b7;
}

/* Settings select */
.setting-label select {
    padding: 6px 10px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #e2e8f0;
    font-size: 13px;
    cursor: pointer;
}

/* =====================================================
   READY FOR DELETION TABLE
   ===================================================== */
.deletion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.deletion-header h3 {
    color: #f8fafc;
    font-size: 16px;
    font-weight: 500;
    margin: 0;
}

.btn-refresh {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-refresh:hover {
    background: #2563eb;
}

.table-responsive {
    overflow-x: auto;
}

.deletion-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.deletion-table th {
    background: #0f172a;
    color: #94a3b8;
    font-weight: 500;
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid #334155;
}

.deletion-table td {
    padding: 12px;
    border-bottom: 1px solid #1e293b;
    color: #e2e8f0;
}

.deletion-table tr:hover {
    background: #1e293b;
}

/* Invoice link */
.invoice-link {
    color: #60a5fa;
    text-decoration: none;
    font-weight: 500;
}

.invoice-link:hover {
    text-decoration: underline;
}

/* Client info */
.client-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.client-name {
    font-weight: 500;
    color: #f8fafc;
}

.client-email {
    font-size: 12px;
    color: #94a3b8;
}

/* Days overdue */
.days-overdue {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
}

.days-overdue.critical {
    background: #7f1d1d;
    color: #fca5a5;
}

.days-overdue.warning {
    background: #78350f;
    color: #fcd34d;
}

/* Amount */
.amount {
    font-weight: 600;
    color: #f8fafc;
}

/* Business badge */
.business-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #1e293b;
    border-radius: 4px;
    font-size: 13px;
}

/* Service badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    margin-right: 4px;
}

.badge.mapped {
    background: #065f46;
    color: #6ee7b7;
}

.badge.unmapped {
    background: #78350f;
    color: #fcd34d;
}

/* Workflow stage badges */
.badge.stage-pending {
    background: #475569;
    color: #94a3b8;
}

.badge.stage-suspended {
    background: #7f1d1d;
    color: #fca5a5;
}

.badge.stage-deletion_warning {
    background: #78350f;
    color: #fcd34d;
}

.badge.stage-terminated {
    background: #1f2937;
    color: #6b7280;
}

.badge.stage-unsuspended {
    background: #065f46;
    color: #6ee7b7;
}

/* =====================================================
   PROVIDER/IP CELL STYLES
   ===================================================== */
.provider-ip-cell {
    min-width: 160px;
}

/* Stack provider name and IP vertically like invoice column */
.provider-ip-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 3px 0;
}

.provider-ip-row + .provider-ip-row {
    border-top: 1px solid #334155;
    margin-top: 4px;
    padding-top: 6px;
}

.provider-ip-row.mapped .provider-name-small {
    color: #6ee7b7;
}

.provider-ip-row.unmapped .provider-name-small {
    color: #fcd34d;
}

.provider-name-small {
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
}

.ip-small {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 11px;
    color: #94a3b8;
    background: none;
    padding: 0;
}

.more-services {
    font-size: 11px;
    color: #64748b;
    font-style: italic;
    margin-top: 4px;
}

.no-services {
    font-size: 12px;
    color: #64748b;
    font-style: italic;
}

/* Business badge under invoice */
.business-small {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}

/* Action buttons */
.actions {
    display: flex;
    gap: 8px;
}

.btn-action {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-view {
    background: #1e3a5f;
    color: #60a5fa;
}

.btn-view:hover {
    background: #1e40af;
    color: white;
}

.btn-delete {
    background: #7f1d1d;
    color: #fca5a5;
}

.btn-delete:hover {
    background: #991b1b;
    color: white;
}

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 15px;
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 8px;
}

.empty-hint {
    font-size: 13px;
    color: #64748b;
}

/* =====================================================
   AUTOMATION SETTINGS
   ===================================================== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.setting-item {
    background: #0f172a;
    padding: 15px;
    border-radius: 6px;
}

.setting-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #e2e8f0;
    font-weight: 500;
    margin-bottom: 4px;
}

.setting-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.setting-label input[type="number"] {
    width: 60px;
    padding: 4px 8px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #e2e8f0;
    font-size: 14px;
}

.setting-hint {
    font-size: 12px;
    color: #64748b;
}

.settings-status {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.enabled {
    background: #065f46;
    color: #6ee7b7;
}

.status-badge.disabled {
    background: #7f1d1d;
    color: #fca5a5;
}

.status-badge.dry-run {
    background: #78350f;
    color: #fcd34d;
}

/* =====================================================
   AUTOMATION STATS
   ===================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.stat-card {
    background: #0f172a;
    padding: 20px;
    border-radius: 6px;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 13px;
    color: #94a3b8;
}

/* =====================================================
   MODAL STYLES
   ===================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: #1e293b;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #334155;
}

.modal-header h3 {
    margin: 0;
    color: #f8fafc;
    font-size: 16px;
}

.modal-header.danger {
    background: #7f1d1d;
}

.modal-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: #f8fafc;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #334155;
}

/* Warning message in modal */
.warning-message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #7f1d1d;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
}

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

.warning-message p {
    margin: 0;
    color: #fca5a5;
}

.deletion-details {
    background: #0f172a;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
}

.deletion-details p {
    margin: 5px 0;
    color: #e2e8f0;
}

.confirmation-checkbox {
    padding: 10px 0;
}

.confirmation-checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #e2e8f0;
    cursor: pointer;
}

.confirmation-checkbox input {
    width: 18px;
    height: 18px;
}

/* Services modal */
.services-modal {
    max-width: 700px;
}

.invoice-summary {
    background: #0f172a;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
}

.invoice-summary p {
    margin: 5px 0;
    color: #e2e8f0;
}

.services-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.service-item {
    background: #0f172a;
    padding: 12px;
    border-radius: 6px;
    border-left: 3px solid #334155;
}

.service-item.mapped {
    border-left-color: #10b981;
}

.service-item.unmapped {
    border-left-color: #f59e0b;
}

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

.service-name {
    color: #f8fafc;
    font-weight: 500;
}

.service-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    background: #334155;
    color: #94a3b8;
}

.service-status.active {
    background: #065f46;
    color: #6ee7b7;
}

.service-status.suspended {
    background: #78350f;
    color: #fcd34d;
}

.service-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: #94a3b8;
}

/* Buttons */
.btn-secondary {
    background: #334155;
    color: #e2e8f0;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-danger {
    background: #dc2626;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-danger:disabled {
    background: #7f1d1d;
    color: #9ca3af;
    cursor: not-allowed;
}

/* =====================================================
   ANIMATIONS
   ===================================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

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

/* =====================================================
   LOADING STATE
   ===================================================== */
.loading {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
}

.error {
    text-align: center;
    padding: 20px;
    color: #fca5a5;
    background: #7f1d1d;
    border-radius: 6px;
}

/* =====================================================
   RESPONSIVE ADJUSTMENTS
   ===================================================== */
@media (max-width: 768px) {
    #automation-panel.automation-section {
        padding-left: 16px;
        padding-right: 16px;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .deletion-table th,
    .deletion-table td {
        padding: 8px;
        font-size: 13px;
    }

    .actions {
        flex-direction: column;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .provider-ip-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
}
