/* Modern, Clean Design */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #6366f1;
    --success: #059669;
    --warning: #d97706;
    --error: #dc2626;
    --bg: #f9fafb;
    --card-bg: #ffffff;
    --text: #111827;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 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);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* App Wrapper - New Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Fixed Control Panel Sidebar */
.control-panel-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 320px;
    min-width: 0;
    max-width: 500px;
    height: 100vh;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    z-index: 100;
    transition: width 0.2s ease;
}

.control-panel-sidebar.collapsed {
    width: 60px;
}

.control-panel-sidebar.collapsed .control-panel-content {
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

.control-panel-sidebar.collapsed::before {
    content: '☰';
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    color: var(--text-light);
    z-index: 102;
    pointer-events: none;
}

.control-panel-sidebar.collapsed .control-panel-resize-handle {
    right: 0;
    width: 100%;
    cursor: ew-resize;
}

.control-panel-sidebar.collapsed .control-panel-resize-handle::after {
    display: none;
}

/* Resize Handle */
.control-panel-resize-handle {
    position: absolute;
    right: -4px;
    top: 0;
    width: 8px;
    height: 100%;
    background: transparent;
    cursor: ew-resize;
    z-index: 101;
    transition: background 0.2s;
    user-select: none;
    -webkit-user-select: none;
}

.control-panel-resize-handle:hover {
    background: var(--primary);
}

.control-panel-resize-handle:active {
    background: var(--primary-dark);
}

.control-panel-resize-handle::after {
    content: '';
    position: absolute;
    right: -2px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 40px;
    background: var(--border);
    border-radius: 2px;
    transition: background 0.2s;
}

.control-panel-resize-handle:hover::after {
    background: var(--primary);
}

.control-panel-content {
    padding: 24px;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    transition: opacity 0.2s ease;
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.control-panel-content::-webkit-scrollbar {
    width: 8px;
}

.control-panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.control-panel-content::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.control-panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

.control-panel-content h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 0;
    border-bottom: none;
}

.control-panel-content > p {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    margin-bottom: 24px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
}

.control-panel-content .form-group {
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-light);
}

.control-panel-content .form-group:last-of-type {
    border-bottom: none;
}

.control-panel-content label {
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
    margin-bottom: 6px;
    display: block;
}

.control-panel-content small {
    display: block;
    margin-top: 4px;
    color: var(--text-light);
    font-size: 11px;
    line-height: 1.4;
}

/* Main Content Area */
.main-content {
    margin-left: 380px;
    flex: 1;
    padding: 20px;
    min-width: 0;
}

/* Icons */
.icon {
    width: 20px;
    height: 20px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

.icon-header {
    width: 28px;
    height: 28px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 12px;
    color: var(--primary);
}

.icon-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.icon-chevron {
    width: 20px;
    height: 20px;
    color: var(--text-light);
    flex-shrink: 0;
}

.icon-small {
    width: 16px;
    height: 16px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
    color: var(--text-light);
}

.card h2 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--card-bg);
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

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

.btn-danger:hover {
    background: #b91c1c;
    transform: translateY(-2px);
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
}

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

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Live Status Bar */
.live-status-bar {
    background: var(--card-bg);
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    border-left: 4px solid var(--primary);
}

.live-status-content {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.shop-status-compact {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.shop-status-compact.running {
    border-color: var(--primary);
    background: #eff6ff;
}

.shop-status-compact strong {
    font-size: 14px;
    min-width: 120px;
}

.status-badge-compact {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge-compact.active {
    background: var(--primary);
    color: white;
}

.status-badge-compact.completed {
    background: var(--success);
    color: white;
}

.status-badge-compact.failed {
    background: var(--error);
    color: white;
}

.status-badge-compact.inactive {
    background: var(--text-light);
    color: white;
}

/* Dashboard Grid */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border: 1px solid var(--border-light);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--border);
}

.card h2 {
    font-size: 22px;
    margin-bottom: 24px;
    color: var(--text);
    border-bottom: 3px solid var(--border-light);
    padding-bottom: 12px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text);
}

.checkbox-group, .radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.updates-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 8px;
}

.btn-link {
    background: none;
    border: none;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    font-size: inherit;
}

.checkbox-group label, .radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    cursor: pointer;
}

input[type="checkbox"], input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

input[type="number"],
input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.2s;
    background: var(--card-bg);
}

input[type="number"]:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px -2px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
    background: var(--text-light);
    color: white;
}

.btn-small {
    padding: 6px 12px;
    font-size: 14px;
}

/* Runs List */
.runs-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.run-item {
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s;
    cursor: pointer;
}

.run-item:hover {
    border-color: var(--primary);
    background: #f0f9ff;
    cursor: pointer;
}

.run-item.running {
    border-color: var(--primary);
    background: #eff6ff;
}

.run-item.completed {
    border-color: var(--success);
    opacity: 0.6;
    background: var(--card-bg);
}

.run-item.completed:hover {
    opacity: 0.8;
    border-color: var(--border);
    background: var(--card-bg);
}

.run-item.failed {
    border-color: var(--error);
}

.run-item.cancelled {
    opacity: 0.5;
    background: var(--bg);
    border-color: var(--border);
    cursor: pointer;
}

.run-item.cancelled:hover {
    opacity: 0.7;
    border-color: var(--text-light);
}

.run-status.cancelled {
    background: var(--text-light);
    color: white;
}

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

.run-title {
    font-weight: 600;
    font-size: 16px;
}

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

.run-status.running {
    background: var(--primary);
    color: white;
}

.run-status.completed {
    background: var(--success);
    color: white;
}

.run-status.failed {
    background: var(--error);
    color: white;
}

.run-meta {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: var(--text-light);
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.filter-bar select {
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

/* Estimate Result */
.estimate-result {
    margin-top: 16px;
    padding: 16px;
    background: #f0f9ff;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    display: none; /* Hidden by default, shown when content is available */
}

.estimate-result:not(:empty) {
    display: block; /* Show when not empty */
}

/* Bulk Operations */
.bulk-ops-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bulk-op-item {
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.bulk-op-item.clickable:hover {
    border-color: var(--primary);
    background: #f0f9ff;
    transform: translateX(4px);
}

.bulk-op-content {
    flex: 1;
}

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

.bulk-op-details {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-light);
}

.bulk-op-details span {
    display: inline-block;
}

.bulk-ops-list {
    margin-top: 16px;
}

.bulk-op-item {
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Cron Schedules */
.cron-schedules {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cron-item {
    padding: 20px;
    border: 2px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--card-bg);
}

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

.cron-schedule {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cron-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.cron-status.enabled {
    background: var(--success);
    color: white;
}

.cron-status.disabled {
    background: var(--text-light);
    color: white;
}

.cron-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background: var(--card-bg);
    margin: 5% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    color: var(--text-light);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

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

/* Status Grid */
.status-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.shop-status {
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s;
}

.shop-status.running {
    border-color: var(--primary);
    background: #eff6ff;
}

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

.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.active {
    background: var(--success);
    color: white;
}

.status-badge.inactive {
    background: var(--border);
    color: var(--text-light);
}

.status-badge.completed {
    background: var(--success);
    color: white;
}

.status-badge.failed {
    background: var(--error);
    color: white;
}

.bulk-info {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}

.latest-run-info {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
    font-style: italic;
}

/* Custom Modal/Alert */
.custom-modal {
    display: flex;
    position: fixed;
    z-index: 10001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.custom-modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    animation: slideUp 0.3s ease;
}

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

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

.custom-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.custom-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-light);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.custom-modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

.custom-modal-body {
    padding: 24px;
    color: var(--text);
    line-height: 1.6;
}

.custom-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--border);
}

/* Bulk Operation Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--card-bg);
    margin: auto;
    padding: 0;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-close {
    position: absolute;
    right: 20px;
    top: 20px;
    color: var(--text-light);
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    z-index: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--border-light);
    color: var(--text);
}

.detail-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 600;
    color: var(--text-light);
    font-size: 14px;
}

.detail-value {
    color: var(--text);
    font-size: 14px;
    word-break: break-all;
}

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

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

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 16px 20px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    max-width: 420px;
    min-width: 320px;
    pointer-events: none;
    border: 1px solid var(--border);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.toast-success {
    border-left: 4px solid var(--success);
    background: linear-gradient(to right, #f0fdf4 0%, var(--card-bg) 4%);
}

.toast-error {
    border-left: 4px solid var(--error);
    background: linear-gradient(to right, #fef2f2 0%, var(--card-bg) 4%);
}

/* Stack multiple toasts */
.toast + .toast {
    margin-bottom: 12px;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
    animation: pulse-progress 2s infinite;
}

@keyframes pulse-progress {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Stage Progress */
.stage-progress {
    /* Removed slideInUp animation to prevent jumping */
}

.stage-progress-bar {
    position: relative;
    overflow: hidden;
}

.stage-progress-fill {
    position: relative;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    /* Removed shimmer animation to prevent jumping */
}

/* Only show shimmer if actively progressing (not stalled) */
.stage-progress:not(.stalled) .stage-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer-slide 3s infinite;
    animation-play-state: running;
}

.stage-progress.stalled .stage-progress-fill::after {
    animation-play-state: paused;
}

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

@keyframes shimmer {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.9; }
}

@keyframes shimmer-slide {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Bulk Operation - External Warning */
.bulk-op-external {
    border-left: 4px solid var(--warning) !important;
}

/* Removed ::before pseudo-element to prevent duplicate warning text - warning is now shown in JavaScript */

/* Responsive */
@media (max-width: 1200px) {
    .control-panel-sidebar {
        width: 320px;
    }
    
    .main-content {
        margin-left: 320px;
    }
}

@media (max-width: 768px) {
    .control-panel-sidebar {
        position: relative;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .dashboard {
        grid-template-columns: 1fr;
    }
    
    .header {
        flex-direction: column;
        gap: 16px;
    }
    
    .updates-grid {
        grid-template-columns: 1fr;
    }
    
    .live-status-content {
        flex-direction: column;
    }
}

