@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #10b981;
    --primary-hover: #059669;
    --primary-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;

    --bg-app: #ffffff;
    --bg-white: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --text-light: #9ca3af;
    --border-color: #e5e7eb;
    --border-strong: #d1d5db;

    --font-stack: 'Inter', system-ui, -apple-system, sans-serif;
    --sidebar-width: 280px;

    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;

    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.03);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.04), 0 2px 4px -1px rgba(0,0,0,0.02);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.05), 0 8px 10px -6px rgba(0,0,0,0.01);
    --shadow-hover: 0 20px 25px -5px rgba(0,0,0,0.08), 0 10px 10px -5px rgba(0,0,0,0.02);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font-stack);
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

/* ===== LOGIN ===== */
.login-screen {
    position: fixed; inset: 0; background: var(--bg-app);
    display: flex; justify-content: center; align-items: center; z-index: 1000;
}
.login-card {
    background: var(--bg-white); padding: 3rem; border-radius: var(--radius-lg);
    width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); border: 1px solid var(--border-strong);
}
.login-logo {
    display: flex; align-items: center; justify-content: center; gap: 0.75rem;
    font-size: 1.25rem; font-weight: 700; margin-bottom: 0.25rem;
}
.login-subtitle {
    text-align: center; color: var(--text-muted); font-size: 0.9rem; margin-bottom: 2rem;
}
.login-error {
    background: var(--danger-light); color: var(--danger);
    padding: 0.75rem; border-radius: var(--radius-sm);
    font-size: 0.85rem; text-align: center; font-weight: 500;
    margin-bottom: 1.5rem; border: 1px solid var(--danger);
}
.shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}
@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* ===== LAYOUT ===== */
.dashboard-layout { display: flex; min-height: 100vh; }
.hidden { display: none !important; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width); background: var(--bg-white);
    height: 100vh; position: fixed; left: 0; top: 0;
    display: flex; flex-direction: column; border-right: 1px solid var(--border-color);
}
.logo { padding: 2rem 1.75rem; border-bottom: 1px solid var(--border-color); }
.logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--text-main); letter-spacing: -0.04em; }
.logo p { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

.main-nav { flex: 1; padding: 1.5rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.nav-item {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.875rem 1rem;
    color: var(--text-muted); text-decoration: none; border-radius: var(--radius-sm);
    font-weight: 500; transition: var(--transition);
}
.nav-item:hover { background: var(--bg-app); color: var(--text-main); }
.nav-item.active {
    background: #F9FAFB; color: var(--text-main); font-weight: 500;
    border-left: 3px solid var(--primary); border-radius: 0;
}
.sidebar-footer { padding: 1.25rem 1.75rem; }
.cron-status {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem; background: transparent;
    border: none;
    font-size: 0.8rem; color: var(--text-muted); font-weight: 500;
}
.pulse {
    width: 8px; height: 8px; background: var(--primary); border-radius: 50%;
    animation: pulsing 2s infinite;
}
@keyframes pulsing {
    0% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
    70% { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
    100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
.btn-logout {
    width: 100%; margin-top: 0.5rem; padding: 0.5rem;
    background: transparent; border: none; text-align: left;
    color: var(--text-muted); font-size: 0.8rem; font-weight: 500;
    cursor: pointer; transition: var(--transition); font-family: inherit;
}
.btn-logout:hover { color: var(--danger); }

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1; margin-left: var(--sidebar-width); padding: 3rem 4rem; max-width: 1400px;
}
.page-content { display: none; }
.page-content.active { display: block; }

.topbar {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 3rem;
}
.page-title h1 {
    font-size: 2rem; font-weight: 700; color: var(--text-main);
    margin-bottom: 0.35rem; letter-spacing: -0.03em;
}
.page-title p { color: #6B7280; font-size: 0.95rem; }

/* ===== BUTTONS ===== */
.btn-primary {
    background: #059669; color: var(--bg-white); border: none;
    padding: 0.875rem 1.5rem; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 500; cursor: pointer;
    display: inline-flex; align-items: center; gap: 0.6rem;
    transition: var(--transition);
}
.btn-primary:hover { background: #047857; transform: none; box-shadow: none; }
.btn-secondary {
    background: var(--bg-white); color: var(--text-main);
    border: 1px solid var(--border-strong);
    padding: 0.875rem 1.5rem; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    transition: var(--transition); box-shadow: var(--shadow-sm); font-family: inherit;
}
.btn-outline {
    background: rgba(5, 150, 105, 0.08); color: var(--primary);
    border: none; padding: 0.875rem 1.5rem;
    border-radius: var(--radius-sm); font-weight: 500; cursor: pointer;
    transition: var(--transition);
}
.btn-outline:hover {
    background: rgba(5, 150, 105, 0.15);
}

.btn-secondary:hover { background: var(--border-color); }
.w-full { width: 100%; justify-content: center; }
.btn-icon {
    width: 36px; height: 36px; border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); background: var(--bg-white);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: var(--transition); color: var(--text-muted);
}
.btn-icon:hover { background: var(--bg-app); color: var(--text-main); border-color: #d1d5db; }
.btn-icon.danger:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

/* ===== STATS ===== */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem; margin-bottom: 3.5rem;
}
.stat-card {
    background: var(--bg-white); padding: 1.5rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border-color); box-shadow: none;
    transition: var(--transition); position: relative; overflow: hidden;
}
.stat-card:hover { box-shadow: none; transform: none; }
.stat-icon {
    display: none;
}
.stat-card h3 { 
    font-size: 11px; color: #6B7280; font-weight: 600; margin-bottom: 1.5rem; 
    text-transform: uppercase; letter-spacing: 0.05em; 
    padding-bottom: 0.75rem; border-bottom: 1px solid var(--border-color);
}
.stat-value { 
    font-size: 1.125rem; font-weight: 600; color: #374151; letter-spacing: 0; 
    background: #F3F4F6; padding: 0.25rem 0.75rem; border-radius: 9999px; display: inline-block;
}
.text-accent { color: var(--primary); }

/* ===== AUTOMATIONS GRID ===== */
.section-header { margin-bottom: 1.5rem; }
.section-header h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.02em; }
.automations-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1.5rem;
}
.auto-card {
    background: var(--bg-white); border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg); padding: 1.75rem; box-shadow: var(--shadow-sm);
    transition: var(--transition); display: flex; flex-direction: column;
}
.auto-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: #d1d5db; }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.card-title h3 { font-size: 1.05rem; font-weight: 600; color: var(--text-main); }
.card-url { font-size: 0.8rem; color: var(--text-light); }
.status-badge {
    background: var(--primary-light); color: var(--primary-hover);
    padding: 0.3rem 0.7rem; border-radius: 20px; font-size: 0.7rem;
    font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase;
    flex-shrink: 0;
}
.status-badge.paused { background: var(--warning-light); color: #b45309; }
.card-body { flex: 1; margin-bottom: 1rem; }
.card-info-row {
    display: flex; justify-content: space-between; padding: 0.4rem 0;
    font-size: 0.85rem; color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}
.card-info-row:last-child { border-bottom: none; }
.card-info-row strong { color: var(--text-main); }
.card-footer {
    display: flex; gap: 0.5rem; justify-content: flex-end;
    padding-top: 1rem; border-top: 1px solid var(--border-color);
}
.empty-state {
    text-align: center; padding: 5rem 2rem; background: transparent;
    border: none; border-radius: var(--radius-lg);
}
.empty-icon {
    width: 64px; height: 64px; margin: 0 auto 1.5rem auto;
    background: var(--primary-light); border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
}
.empty-state h3 { margin-bottom: 0.5rem; font-size: 1.2rem; font-weight: 600; }
.empty-state p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* Skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--bg-app) 25%, #e5e7eb 50%, var(--bg-app) 75%);
    background-size: 200% 100%; animation: skeleton-loading 1.5s infinite;
    min-height: 200px; border: none;
}
@keyframes skeleton-loading {
    0% { background-position: 200% 0; } 100% { background-position: -200% 0; }
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(17,24,39,0.4); backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: center;
    z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content {
    background: var(--bg-white); padding: 2.5rem; border-radius: var(--radius-lg);
    width: 100%; max-width: 550px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.3);
    transform: scale(0.95) translateY(10px);
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1); opacity: 0;
    max-height: 90vh; overflow-y: auto;
}
.modal-large { max-width: 680px; }
.modal-overlay.active .modal-content { transform: scale(1) translateY(0); opacity: 1; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-header h2 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.close-btn {
    background: none; border: none; font-size: 1.5rem; cursor: pointer;
    color: var(--text-light); transition: color 0.2s;
}
.close-btn:hover { color: var(--text-main); }

/* Steps Indicator */
.steps-indicator {
    display: flex; gap: 0.5rem; margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color); padding-bottom: 1.25rem;
}
.steps-indicator .step {
    flex: 1; text-align: center; font-size: 0.8rem; font-weight: 500;
    color: var(--text-light); padding: 0.5rem; border-radius: var(--radius-sm);
    transition: var(--transition);
}
.steps-indicator .step span {
    display: inline-flex; width: 24px; height: 24px; border-radius: 50%;
    background: var(--border-strong); color: var(--text-muted);
    align-items: center; justify-content: center; margin-right: 0.4rem;
    font-weight: 600; font-size: 0.75rem; transition: var(--transition);
}
.steps-indicator .step.active { color: var(--text-main); }
.steps-indicator .step.active span { background: var(--text-main); color: var(--bg-white); }
.steps-indicator .step.done span { background: var(--primary); color: var(--bg-white); }
.steps-indicator .step.done { color: var(--primary); }

/* Form Steps */
.form-step { display: none; }
.form-step.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.step-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.25rem; }
.step-desc { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

/* Form Elements */
.form-group { margin-bottom: 1.25rem; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
label {
    display: block; font-size: 0.85rem; font-weight: 600;
    margin-bottom: 0.4rem; color: var(--text-main);
}
input, textarea, .input-select {
    width: 100%; padding: 0.75rem 1rem;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font-family: inherit; font-size: 0.9rem; transition: var(--transition);
    background: var(--bg-white); color: var(--text-main);
}
input::placeholder, textarea::placeholder { color: var(--text-light); }
input:focus, textarea:focus, .input-select:focus {
    outline: none; border-color: var(--text-main);
    box-shadow: 0 0 0 3px rgba(17,24,39,0.05);
}
.input-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 1rem center;
    padding-right: 2.5rem; cursor: pointer;
}
.hint-text { font-size: 0.8rem; color: var(--text-light); margin-top: 0.5rem; }

/* Days Grid */
.days-grid { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.day-checkbox {
    display: flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font-size: 0.85rem; cursor: pointer; transition: var(--transition);
    font-weight: 500; color: var(--text-muted);
}
.day-checkbox:has(input:checked) {
    background: var(--primary-light); border-color: var(--primary);
    color: var(--primary-hover);
}
.day-checkbox input { display: none; }

/* Toggle Switch */
.toggle-label {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 0.9rem; font-weight: 500; cursor: pointer;
}
.toggle-switch { position: relative; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0; background: var(--border-strong);
    border-radius: 12px; transition: var(--transition);
}
.toggle-slider::before {
    content: ''; position: absolute; width: 18px; height: 18px;
    left: 3px; bottom: 3px; background: var(--bg-white);
    border-radius: 50%; transition: var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Modal Footer */
.modal-footer { display: flex; align-items: center; gap: 0.75rem; margin-top: 2rem; }

/* ===== TABLE ===== */
.table-container { overflow-x: auto; }
.data-table {
    width: 100%; border-collapse: collapse; background: var(--bg-white);
    border-radius: var(--radius-lg); overflow: hidden;
    border: 1px solid var(--border-strong);
}
.data-table th {
    text-align: left; padding: 0.875rem 1.25rem; font-size: 0.8rem;
    font-weight: 600; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.04em; background: var(--bg-app); border-bottom: 1px solid var(--border-strong);
}
.data-table td {
    padding: 0.875rem 1.25rem; font-size: 0.9rem; color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-app); }
.table-empty { text-align: center; color: var(--text-light); padding: 3rem !important; }
.table-badge {
    padding: 0.25rem 0.6rem; border-radius: 12px; font-size: 0.75rem;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
}
.table-badge.green { background: var(--primary-light); color: var(--primary-hover); }
.table-badge.red { background: var(--danger-light); color: var(--danger); }
.table-badge.yellow { background: var(--warning-light); color: #b45309; }
.table-link { color: var(--primary); text-decoration: none; font-weight: 500; }
.table-link:hover { text-decoration: underline; }
.filter-group { display: flex; gap: 0.75rem; }

/* ===== ADMIN ===== */
.admin-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem;
}
.admin-card {
    background: var(--bg-white); padding: 2rem; border-radius: var(--radius-lg);
    border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm);
}
.admin-card.full-width { grid-column: 1 / -1; }
.admin-card h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.35rem; }
.admin-card > p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.25rem; }
.status-list { display: flex; flex-direction: column; gap: 0.75rem; }
.status-item { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.status-dot.green { background: var(--primary); }
.status-dot.yellow { background: var(--warning); }
.status-dot.red { background: var(--danger); }
.force-run-row { display: flex; gap: 0.75rem; align-items: flex-end; }
.force-run-row .input-select { flex: 1; }
