/* ============================================================
   SHARED COMPONENTS — Buttons, Forms, Error Message
   ============================================================ */

/* Error message (shared across login, admin forms) */
.error-message {
    color: var(--error);
    font-size: 14px;
    margin-bottom: 0;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.12);
    border-radius: var(--radius-sm);
    display: none;
}

.error-message.show { display: block; }

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 12px 24px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-normal);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.20);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

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

.btn-secondary {
    padding: 10px 20px;
    background: var(--bg-white);
    color: var(--text-primary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-normal);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-icon {
    padding: 8px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Form groups (shared) */
.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    box-sizing: border-box;
}

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

/* Custom dropdown arrow for select */
.form-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
    cursor: pointer;
}

.form-group select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background-color: var(--bg-tertiary);
}

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

.combobox-select-root {
    width: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

.combobox-select-input {
    width: 100%;
    padding: 12px 16px;
    padding-right: 38px;
    cursor: text;
    background-color: var(--bg-white);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.combobox-select-root.open .combobox-select-input {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.combobox-select-list,
.combobox-select-empty {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 2500;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.combobox-select-list {
    max-height: 240px;
    overflow-y: auto;
    display: none;
    padding: 6px;
}

.combobox-select-empty {
    display: none;
    padding: 10px 12px;
    color: var(--text-muted);
    font-size: 13px;
}

.combobox-select-option {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    font-size: 14px;
    line-height: 1.35;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.combobox-select-option:hover {
    background: var(--bg-tertiary);
}

.combobox-select-option.selected {
    background: rgba(37, 99, 235, 0.08);
    color: var(--text-primary);
    font-weight: 500;
}

.combobox-select-option:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.combobox-native-hidden {
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 1px !important;
    height: 1px !important;
    left: 0 !important;
    top: 0 !important;
}

.table-selector-row .combobox-select-root {
    flex: 1;
    min-width: 180px;
}

/* Wizard selects (outside .form-group, e.g. table-selector-row) */
select {
    color: var(--text-primary);
    font-family: inherit;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */

.app-container {
    display: flex;
    width: 100%;
    overflow-x: hidden;
    height: 100vh;
    overflow: hidden;
    max-width: 100vw;
}

/* ── Sidebar ────────────────────────────────────────── */

.sidebar {
    width: 320px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 28px 24px 24px;
    display: flex;
    align-items: center;
}

.sidebar-nav {
    padding: 0 20px 18px;
}

.sidebar-nav-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.08), rgba(37, 99, 235, 0.04));
    border: 1px solid rgba(37, 99, 235, 0.12);
    border-radius: var(--radius-md);
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.sidebar-nav-btn:hover {
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.12), rgba(37, 99, 235, 0.06));
    border-color: rgba(37, 99, 235, 0.22);
    transform: translateY(-1px);
}

.sidebar-nav-btn img {
    flex-shrink: 0;
}

.logo-small {
    display: flex;
    align-items: center;
    gap: 14px;
    transition: opacity var(--transition-fast);
}

.logo-small:hover { opacity: 0.75; }

.company-logo-wrapper {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.company-logo {
    height: 28px;
    width: 28px;
    object-fit: contain;
}

.logo-small span {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    -webkit-text-fill-color: var(--text-dark);
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.25;
    vertical-align: middle;
}

.logo-small span small,
.sub-text {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    display: block;
    color: var(--primary);
    -webkit-text-fill-color: var(--primary);
}

.sidebar-section {
    padding: 8px 20px 20px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-section h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 0.08em;
    margin-bottom: 20px;
    padding-bottom: 0;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-item {
    padding: 12px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.history-item:last-child { margin-bottom: 0; }

.history-item:hover {
    background: var(--bg-hover);
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.history-item-content {
    flex: 1;
    cursor: pointer;
    min-width: 0;
    overflow: hidden;
    transition: opacity var(--transition-fast);
}

.history-item-content:hover { opacity: 0.7; }

.history-item-pin,
.history-item-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    opacity: 0;
}

.history-item:hover .history-item-delete,
.history-item:hover .history-item-pin { opacity: 0.5; }

.history-item-pin:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
    opacity: 1 !important;
}

.history-item-pin.is-pinned {
    opacity: 1;
    color: #d4a017;
    background: rgba(212, 160, 23, 0.12);
}

.history-item-delete:hover {
    background: rgba(239, 68, 68, 0.06);
    color: var(--error);
    opacity: 1 !important;
}

.history-item-pin img { display: block; width: 14px; height: 14px; }
.history-item-delete svg { display: block; width: 14px; height: 14px; }

.history-item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.history-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    font-weight: 500;
}

/* Status badge (dot indicator) */
.status-badge {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    padding: 0;
    font-size: 0;
    line-height: 0;
    text-indent: -9999px;
    overflow: hidden;
    vertical-align: middle;
    flex-shrink: 0;
}

.status-badge.completed { background: var(--success); color: transparent; }
.status-badge.processing { background: var(--warning); color: transparent; }
.status-badge.queued,
.status-badge.running { background: var(--primary); color: transparent; }
.status-badge.cancelled { background: var(--text-muted); color: transparent; }
.status-badge.error { background: var(--error); color: transparent; }

/* Sidebar admin section */
.sidebar-admin-section {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.sidebar-admin-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: var(--radius-md);
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.sidebar-admin-btn:hover { background: rgba(37, 99, 235, 0.15); }

/* Sidebar footer */
.sidebar-footer {
    position: relative;
    padding: 20px;
    border-top: 1px solid var(--border);
}

.sidebar-security-btn {
    display: none;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-bottom: 6px;
    padding: 10px 12px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.24);
    border-radius: var(--radius-md);
    color: #92400e;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.sidebar-security-btn:hover {
    background: rgba(245, 158, 11, 0.18);
    border-color: rgba(245, 158, 11, 0.34);
}

.sidebar-security-btn svg { flex-shrink: 0; }

.sidebar-footer.mfa-reset-enabled:hover .sidebar-security-btn,
.sidebar-footer.mfa-reset-enabled:focus-within .sidebar-security-btn {
    display: flex;
}

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    padding: 8px 0;
    transition: color var(--transition-fast);
    font-family: inherit;
    width: 100%;
}

.sidebar-logout-btn:hover { color: var(--text-dark); }
.sidebar-logout-btn svg { flex-shrink: 0; }
.sidebar-logout-btn span { font-size: 14px; }

/* ── Mobile Menu Button ─────────────────────────────── */

.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    width: 48px;
    height: 48px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
}

.mobile-menu-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.mobile-menu-btn:hover svg { stroke: #ffffff; }
.mobile-menu-btn svg { stroke: var(--text-dark); transition: stroke var(--transition-fast); }

.mobile-menu-btn.open {
    background: var(--primary);
    border-color: var(--primary);
    left: 340px;
}

.mobile-menu-btn.open svg { stroke: #ffffff; }

/* ── Main Content ───────────────────────────────────── */

.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px 40px;
    background: var(--bg-primary);
    max-width: 100%;
}

.content-section {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.content-section.active { display: block; }
