/* =========================================
   InfoSwitch-inspired CSS for Imapsync UI
   ========================================= */

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

:root {
    --primary: #0066CC;
    --primary-dark: #0052A3;
    --primary-light: #E8F0FE;
    --accent-dark: #1A1A2E;
    --accent-dark-lighter: #252540;
    --bg-white: #FFFFFF;
    --bg-gray: #F8F9FC;
    --text-dark: #1E293B;
    --text-muted: #64748B;
    --text-light: #94A3B8;
    --border: #E2E8F0;
    --success: #22C55E;
    --success-bg: #F0FDF4;
    --warning: #F59E0B;
    --warning-bg: #FFFBEB;
    --danger: #EF4444;
    --danger-bg: #FEF2F2;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-gray);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
}

/* ---- NAVBAR ---- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.navbar-brand .icon {
    font-size: 1.5rem;
}

.navbar-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

.status-dot.idle {
    background: var(--text-light);
    animation: none;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.3);
    }
}

/* ---- MAIN LAYOUT ---- */
.main-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ---- HERO ---- */
.hero {
    text-align: center;
    padding: 2.5rem 1rem 2rem;
}

.hero h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.hero p {
    color: var(--text-muted);
    font-size: 1rem;
    max-width: 560px;
    margin: 0 auto;
}

/* ---- SECTION CARDS ---- */
.section-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    margin-bottom: 1rem;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

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

.section-card summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: background 0.15s ease;
}

.section-card summary::-webkit-details-marker {
    display: none;
}

.section-card summary::after {
    content: '';
    margin-left: auto;
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.section-card[open] summary::after {
    transform: rotate(180deg);
}

.section-card summary:hover {
    background: var(--bg-gray);
}

.section-card .section-icon {
    font-size: 1.2rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.section-body {
    padding: 0 1.25rem 1.25rem;
    border-top: 1px solid var(--border);
}

/* ---- FORM GRID ---- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding-top: 1rem;
}

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

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

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-group label .flag-name {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 400;
    text-transform: none;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="email"],
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-dark);
    background: var(--bg-white);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.12);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-light);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

/* ---- CHECKBOX / TOGGLE GROUPS ---- */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
    padding-top: 1rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-gray);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 0.88rem;
}

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

.checkbox-item input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.checkbox-item .cb-label {
    color: var(--text-dark);
    font-weight: 500;
}

.checkbox-item .cb-flag {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--text-light);
}

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.25);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.35);
    transform: translateY(-1px);
}

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

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

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

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

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

.btn-full {
    width: 100%;
}

.actions-bar {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* ---- LOG / RESULT PANEL ---- */
.result-panel {
    margin-top: 1.5rem;
    display: none;
}

.result-panel.visible {
    display: block;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.result-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-container {
    background: var(--border);
    border-radius: 100px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #3B82F6);
    border-radius: 100px;
    width: 0%;
    transition: width 0.5s ease;
}

.progress-bar.done {
    background: linear-gradient(90deg, var(--success), #34D399);
}

.progress-bar.error {
    background: linear-gradient(90deg, var(--danger), #F87171);
}

.log-box {
    background: var(--accent-dark);
    color: #E2E8F0;
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.7;
    max-height: 450px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-box::-webkit-scrollbar {
    width: 6px;
}

.log-box::-webkit-scrollbar-track {
    background: var(--accent-dark-lighter);
    border-radius: 3px;
}

.log-box::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}

/* ---- PROGRESS TEXT ---- */
.progress-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ---- ALERTS ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-info {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid rgba(0, 102, 204, 0.15);
}

.alert-success {
    background: var(--success-bg);
    color: #166534;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.alert-warning {
    background: var(--warning-bg);
    color: #92400E;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-danger {
    background: var(--danger-bg);
    color: #991B1B;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ---- COMMAND PREVIEW ---- */
.cmd-preview {
    background: var(--accent-dark);
    color: #A5B4FC;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    margin-top: 1rem;
    white-space: pre-wrap;
    word-break: break-all;
    position: relative;
}

.cmd-preview::before {
    content: '$ ';
    color: var(--success);
    font-weight: 700;
}

/* ---- SEPARATOR ---- */
.section-sep {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0.75rem 0;
    font-size: 0.78rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.section-sep::before,
.section-sep::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ---- HELP TOOLTIP ---- */
.help-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-light);
    font-size: 0.65rem;
    font-weight: 700;
    cursor: help;
    position: relative;
}

.help-tip:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-dark);
    color: #E2E8F0;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 400;
    white-space: nowrap;
    z-index: 200;
    box-shadow: var(--shadow-lg);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 700px) {
    .main-container {
        padding: 1rem 1rem 3rem;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

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

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

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

    .navbar {
        padding: 0 1rem;
    }
}

/* ---- LOADING SPINNER ---- */
.spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: none;
}

.btn-primary.loading .spinner {
    display: inline-block;
}

.btn-primary.loading .btn-label {
    opacity: 0.7;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---- FOOTER ---- */
.footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-light);
    font-size: 0.82rem;
}

.footer a {
    color: var(--primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}