/* ===== Variables ===== */
:root {
    --blue: #143966;
    --blue-light: #1a4a80;
    --blue-dark: #0e2a4d;
    --white: #ffffff;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #adb5bd;
    --gray-500: #6c757d;
    --gray-600: #495057;
    --gray-700: #343a40;
    --gray-800: #212529;
    --green: #28a745;
    --yellow: #f0ad4e;
    --red: #dc3545;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; color: var(--gray-700); line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }

/* ===== Login Page ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-50);
}

.login-container {
    width: 100%;
    max-width: 440px;
    padding: 20px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 48px 40px;
    text-align: center;
}

.login-logo {
    max-width: 220px;
    height: auto;
    margin-bottom: 32px;
}

.login-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--blue);
    margin-bottom: 6px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 28px;
}

.login-form { text-align: left; }

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

.form-group input[type="email"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 15px;
    color: var(--gray-800);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-group input[type="email"]:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(20, 57, 102, 0.12);
}

.form-group input[type="email"]::placeholder { color: var(--gray-400); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    width: 100%;
    background: var(--blue);
    color: var(--white);
}

.btn-primary:hover { background: var(--blue-light); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-outline {
    background: transparent;
    color: var(--white);
    border: 1px solid rgba(255,255,255,0.4);
    padding: 6px 16px;
    font-size: 13px;
}

.btn-outline:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.7); }

.btn-sm { padding: 6px 16px; font-size: 13px; }

.spinner { width: 18px; height: 18px; }

/* ===== Success/Error Messages ===== */
.success-message {
    padding: 20px 0;
}

.success-icon {
    width: 56px;
    height: 56px;
    background: #e8f5e9;
    color: var(--green);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 16px;
}

.success-message h2 {
    color: var(--gray-800);
    font-size: 18px;
    margin-bottom: 8px;
}

.success-message p {
    color: var(--gray-500);
    font-size: 14px;
}

.error-message {
    margin-top: 12px;
    padding: 10px 14px;
    background: #fef2f2;
    color: var(--red);
    border-radius: var(--radius);
    font-size: 14px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: var(--gray-400);
}

/* ===== Header ===== */
.header {
    background: var(--blue);
    color: var(--white);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.header-logo {
    height: 34px;
    width: auto;
    filter: brightness(0) invert(1);
}

.header-divider {
    width: 1px;
    height: 24px;
    background: rgba(255,255,255,0.25);
}

.header-title {
    font-size: 15px;
    font-weight: 500;
    opacity: 0.9;
}

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

.header-user {
    font-size: 13px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-role-badge {
    background: rgba(255,255,255,0.15);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Dashboard ===== */
.dashboard-page { background: var(--gray-50); min-height: 100vh; }

.main-content { padding: 32px 0; }

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

.page-header { margin-bottom: 28px; }

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--gray-500);
}

/* ===== Integration Cards ===== */
.integration-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 20px;
    margin-bottom: 36px;
}

.integration-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--gray-200);
    transition: box-shadow 0.2s;
}

.integration-card:hover { box-shadow: var(--shadow-lg); }

.card-disabled { opacity: 0.65; }

.card-header { padding: 20px 24px 12px; }

.card-title-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.card-title-group h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
}

.card-desc {
    font-size: 13px;
    color: var(--gray-500);
}

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

.status-active { background: #e8f5e9; color: #2e7d32; }
.status-coming-soon { background: var(--gray-100); color: var(--gray-500); }

.card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--gray-200);
    border-top: 1px solid var(--gray-200);
}

.stat {
    background: var(--white);
    padding: 16px;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--blue);
}

.stat-label {
    display: block;
    font-size: 11px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

.card-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.last-sync { font-size: 12px; color: var(--gray-500); }

/* ===== Data Table ===== */
.table-section {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.table-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.table-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.data-table td {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-100);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: var(--gray-50); }

.platform-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(20, 57, 102, 0.08);
    color: var(--blue);
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.status-success { background: var(--green); }
.status-warning { background: var(--yellow); }
.status-error { background: var(--red); }

/* ===== Sub Navigation ===== */
.sub-nav {
    background: rgba(20, 57, 102, 0.06);
    border-bottom: 1px solid rgba(20, 57, 102, 0.1);
}

.sub-nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    gap: 0;
    overflow-x: auto;
}

.sub-nav-link {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--blue);
    opacity: 0.6;
    border-bottom: 2px solid transparent;
    transition: opacity 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.sub-nav-link:hover { opacity: 1; }

.sub-nav-link.active {
    opacity: 1;
    font-weight: 600;
    border-bottom-color: var(--blue);
}

/* ===== Stat Links ===== */
.stat-link {
    display: block;
    color: inherit;
    text-decoration: none;
}
.stat-link:hover .stat-value { color: var(--blue-light); }

/* ===== Sync Result Banner ===== */
.sync-result {
    padding: 12px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 20px;
}
.sync-success { background: #e8f5e9; color: #2e7d32; }
.sync-warning { background: #fff3e0; color: #e65100; }
.sync-error { background: #fef2f2; color: var(--red); }

/* ===== Status Badge Variants ===== */
.status-error-badge { background: #fef2f2; color: var(--red); }

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
}

.pagination-link {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--blue);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    transition: background 0.2s;
}

.pagination-link:hover { background: var(--gray-50); }

.pagination-info {
    font-size: 13px;
    color: var(--gray-500);
}

/* ===== Cron Settings ===== */
.cron-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.cron-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}

.cron-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.cron-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
}

.cron-card-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--blue);
    display: flex;
    align-items: center;
    gap: 10px;
}

.cron-card-header h3::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
}

.cron-card.is-disabled .cron-card-header h3::before {
    background: var(--gray-300);
}

.cron-card-body {
    padding: 0 24px 20px;
}

.cron-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.cron-select {
    width: 100%;
    padding: 11px 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--gray-700);
    background: var(--gray-50);
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.cron-select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(20,57,102,0.1);
    background-color: var(--white);
}

.cron-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    font-size: 12px;
    color: var(--gray-400);
}

.cron-expression code {
    background: rgba(20, 57, 102, 0.06);
    color: var(--blue);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    font-family: 'SF Mono', 'Consolas', monospace;
}

.cron-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

.cron-card-footer .btn {
    border-radius: 6px;
    font-size: 13px;
    padding: 8px 18px;
    width: auto;
}

.cron-status {
    font-size: 13px;
    font-weight: 600;
    transition: opacity 0.3s;
}
.cron-status-ok { color: var(--green); }
.cron-status-off { color: var(--gray-400); }

/* ===== Toggle Switch ===== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--gray-300);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--white);
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .toggle-slider { background-color: var(--blue); }
input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header-inner { padding: 0 16px; }
    .header-user { display: none; }
    .integration-grid { grid-template-columns: 1fr; }
    .cron-grid { grid-template-columns: 1fr; }
    .login-card { padding: 32px 24px; }
    .container { padding: 0 16px; }
    .sub-nav-inner { padding: 0 16px; }
}
