/* MailSync - Vanilla CSS */

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --light: #f8fafc;
    --dark: #1e293b;
    --border: #e2e8f0;
    --text: #334155;
    --text-muted: #94a3b8;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--light);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.logo-by {
    font-weight: 400;
    font-size: 0.7em;
    color: var(--secondary);
}

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

.nav a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav a:hover {
    color: var(--primary);
}

.user-info {
    color: var(--text-muted);
    font-size: 14px;
}

/* Main Content */
.main {
    flex: 1;
    padding: 40px 0;
}

/* Footer */
.footer {
    background: white;
    border-top: 1px solid var(--border);
    padding: 20px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* Typography */
h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--dark);
}

h2 {
    font-size: 22px;
    font-weight: 600;
    margin: 32px 0 16px;
    color: var(--dark);
}

h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--dark);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--light);
}

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

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

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

.btn-full {
    width: 100%;
}

.btn-google {
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 12px 24px;
    font-size: 16px;
}

.btn-google:hover {
    background: var(--light);
    box-shadow: var(--shadow-lg);
}

.google-icon {
    width: 20px;
    height: 20px;
}

/* Forms */
.form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-card {
    background: white;
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 600px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-weight: 500;
    font-size: 14px;
    color: var(--dark);
}

.form-group small {
    color: var(--text-muted);
    font-size: 12px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.form-inline {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-inline .form-group {
    flex: 1;
    min-width: 200px;
}

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

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

/* Tables */
.table {
    width: 100%;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-collapse: collapse;
    overflow: visible;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--light);
    font-weight: 600;
    font-size: 13px;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    font-size: 14px;
}

.table tbody tr:hover {
    background: var(--light);
}

.table tbody tr {
    position: relative;
}

.table td {
    position: relative;
    overflow: visible;
}

.table .actions {
    display: flex;
    gap: 8px;
}

/* Cards */
.card {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.user-info-card {
    background: white;
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 600px;
}

.user-info-card p {
    margin-bottom: 12px;
}

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

.stat-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-number {
    font-size: 36px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 8px;
}

.stat-label {
    color: var(--secondary);
    font-size: 14px;
    font-weight: 500;
}

/* Status Badges */
.status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-transform: capitalize;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-active,
.status-completed {
    background: #dcfce7;
    color: #166534;
}

.status-running {
    background: #dbeafe;
    color: #1e40af;
}

.status-paused {
    background: #e2e8f0;
    color: #475569;
}

.status-error,
.status-failed {
    background: #fee2e2;
    color: #991b1b;
}

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Info Box */
.info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
}

.info-box h3 {
    color: #1e40af;
    margin-bottom: 8px;
}

.info-box code {
    background: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.info-box pre {
    background: white;
    padding: 12px;
    border-radius: var(--radius);
    margin-top: 12px;
    overflow-x: auto;
    font-size: 13px;
}

/* Actions Bar */
.actions-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    margin: 20px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.divider span {
    padding: 0 16px;
    font-size: 14px;
}

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    margin-bottom: 8px;
}

.login-box .subtitle {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.login-box .description {
    color: var(--text);
    font-size: 14px;
    margin-bottom: 24px;
    line-height: 1.5;
}

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

.admin-link,
.back-link {
    margin-top: 24px;
    font-size: 14px;
}

.admin-link a,
.back-link a {
    color: var(--primary);
    text-decoration: none;
}

.admin-link a:hover,
.back-link a:hover {
    text-decoration: underline;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Info Text */
.info-text {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* Text Utilities */
.text-muted {
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        gap: 15px;
    }

    .nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .table {
        display: block;
        overflow-x: auto;
    }

    .form-inline {
        flex-direction: column;
    }

    .actions-bar {
        flex-direction: column;
    }
}

/* Additional Button Styles */
.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #16a34a;
}

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

.btn-warning:hover {
    background: #d97706;
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 9999;
    margin-top: 4px;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
    color: var(--text);
}

.dropdown-item:hover {
    background: var(--light);
}

.dropdown-item.text-danger,
.text-danger {
    color: var(--danger);
}

/* Table Actions - wrap for many buttons */
.table .actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

/* Status cancelled */
.status-cancelled {
    background: #e2e8f0;
    color: #475569;
}

/* Card Header Flex */
.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header-flex h3 {
    margin: 0;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.chart-card h3 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 16px;
    color: #64748b;
}

.chart-container {
    position: relative;
    height: 200px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 180px;
    padding-top: 20px;
}

.bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 60px;
}

.bar {
    width: 40px;
    background: linear-gradient(180deg, #2563eb, #1d4ed8);
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease;
    min-height: 4px;
}

.bar-label {
    margin-top: 8px;
    font-size: 11px;
    color: #64748b;
    text-align: center;
}

.bar-value {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.bar-today .bar {
    background: linear-gradient(180deg, #22c55e, #16a34a);
}

.bar-today .bar-label {
    font-weight: 600;
    color: #22c55e;
}

/* Donut Chart */
.donut-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.donut-chart {
    position: relative;
    width: 140px;
    height: 140px;
}

.donut-chart svg {
    transform: rotate(-90deg);
}

.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.donut-center .number {
    font-size: 28px;
    font-weight: 700;
    color: #1e293b;
}

.donut-center .label {
    font-size: 12px;
    color: #64748b;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-color.active { background: #22c55e; }
.legend-color.pending { background: #f59e0b; }
.legend-color.paused { background: #64748b; }
.legend-color.error { background: #ef4444; }

/* Logs Page */
.log-filters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.log-stats {
    display: flex;
    gap: 15px;
}

.log-stat {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.log-stat.info {
    background: #e0f2fe;
    color: #0369a1;
}

.log-stat.warning {
    background: #fef3c7;
    color: #b45309;
}

.log-stat.error {
    background: #fee2e2;
    color: #dc2626;
}

.log-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.log-table-container {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.log-table {
    margin: 0;
    font-size: 13px;
}

.log-table th {
    background: #f8fafc;
    font-weight: 600;
    text-align: left;
    padding: 12px 15px;
    border-bottom: 2px solid var(--border);
}

.log-table td {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.log-row.log-error {
    background: #fef2f2;
}

.log-row.log-warning {
    background: #fffbeb;
}

.log-date {
    white-space: nowrap;
    color: var(--text-muted);
    font-family: monospace;
    font-size: 12px;
}

.log-level {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.log-level-info {
    background: #e0f2fe;
    color: #0369a1;
}

.log-level-warning {
    background: #fef3c7;
    color: #b45309;
}

.log-level-error {
    background: #fee2e2;
    color: #dc2626;
}

.log-user {
    color: var(--text-muted);
}

.log-message {
    word-break: break-word;
    font-family: monospace;
    font-size: 12px;
}

/* Sync Progress */
.sync-progress-card {
    background: white;
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
}

.sync-progress-card h2 {
    margin-bottom: 20px;
    color: var(--dark);
}

.sync-running {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--success);
    font-weight: 600;
    margin-bottom: 15px;
}

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

@keyframes pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
    100% { opacity: 1; transform: scale(1); }
}

.progress-bar-container {
    position: relative;
    height: 30px;
    background: #e2e8f0;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 20px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #16a34a);
    border-radius: 15px;
    transition: width 0.5s ease;
    min-width: 2%;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 700;
    font-size: 14px;
    color: var(--dark);
    text-shadow: 0 0 2px white;
}

.progress-numbers {
    display: flex;
    justify-content: space-around;
    gap: 20px;
}

.stat-box {
    text-align: center;
    padding: 15px 25px;
    background: #f8fafc;
    border-radius: var(--radius);
    flex: 1;
}

.stat-box .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.stat-box .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 5px;
}

.user-info-card {
    background: white;
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
}

/* Mini Progress (for diagnose page) */
.mini-progress {
    margin: 15px 0;
}

.mini-progress .progress-bar-container {
    height: 10px;
    margin-bottom: 0;
}

.mini-progress .progress-bar {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

/* Progress Stats */
.progress-stats {
    margin-top: 10px;
}

/* Sync Status Indicator */
.sync-status-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
    margin-bottom: 15px;
}

.sync-status-indicator.running {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.sync-status-indicator.idle {
    background: #f8fafc;
    border-color: #e2e8f0;
}

/* Responsive Progress Numbers */
@media (max-width: 600px) {
    .progress-numbers {
        flex-direction: column;
        gap: 10px;
    }

    .stat-box {
        padding: 12px 15px;
    }

    .stat-box .stat-value {
        font-size: 20px;
    }
}
