/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f5f5;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: #1a1a2e;
}

.hint {
    color: #888;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Options row (version + model dropdowns) */
.options-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #555;
}

.option-group select {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
    color: #333;
}

.option-group select:focus {
    outline: none;
    border-color: #4B9CD3;
    box-shadow: 0 0 0 3px rgba(75, 156, 211, 0.15);
}

.option-group input[type="password"] {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    background: white;
    color: #333;
}

.option-group input[type="password"]:focus {
    outline: none;
    border-color: #4B9CD3;
    box-shadow: 0 0 0 3px rgba(75, 156, 211, 0.15);
}

.password-group {
    margin-bottom: 1.5rem;
}

.model-hint {
    color: #888;
    font-size: 0.8rem;
    font-style: italic;
    margin-bottom: 1.5rem;
    min-height: 1.2em;
}

.operation-descriptions {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.operation-descriptions p {
    color: #666;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.operation-descriptions p:last-child {
    margin-bottom: 0;
}

.operation-descriptions strong {
    color: #444;
}

/* Upload area */
.upload-area {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 1.5rem;
}

.upload-area:hover {
    border-color: #4B9CD3;
    background: #f8fbfd;
}

.upload-area.dragover {
    border-color: #4B9CD3;
    background: #e8f4fc;
}

.upload-area.hidden {
    display: none;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: #999;
    margin-bottom: 1rem;
}

.upload-content p {
    color: #666;
}

.upload-content .link {
    color: #4B9CD3;
    text-decoration: underline;
}

/* File info */
.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f0f7fc;
    border: 1px solid #4B9CD3;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.file-info.hidden {
    display: none;
}

#file-name {
    color: #1a1a2e;
    font-weight: 500;
    word-break: break-all;
}

.btn-clear {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    padding: 0 0.5rem;
    line-height: 1;
}

.btn-clear:hover {
    color: #e74c3c;
}

/* Buttons */
.btn {
    display: block;
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #4B9CD3;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #3a8bc2;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
    margin-top: 1rem;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* Processing spinner */
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #f0f0f0;
    border-top-color: #4B9CD3;
    border-radius: 50%;
    margin: 1rem auto;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#processing-status {
    text-align: center;
    color: #666;
}

#processing-section .hint {
    text-align: center;
    margin-top: 0.5rem;
}

/* Error */
.error-text {
    color: #e74c3c;
    background: #fdf2f2;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* Success */
#success-section p {
    color: #666;
    margin-bottom: 1.5rem;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* User info in header */
.user-info {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: #f0f7fc;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.user-name {
    font-weight: 600;
    color: #1a1a2e;
}

.user-email {
    color: #666;
    font-size: 0.875rem;
}

.logout-link {
    color: #4B9CD3;
    text-decoration: none;
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

.logout-link:hover {
    text-decoration: underline;
}

.admin-link {
    color: white;
    background: #e74c3c;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.admin-link:hover {
    background: #c0392b;
}

.super-admin-link {
    background: #8b0000;
}

.super-admin-link:hover {
    background: #6b0000;
}

/* Authentication required */
.auth-required {
    text-align: center;
    padding: 2rem;
    border: 2px dashed #ddd;
    border-radius: 8px;
    background: #fafafa;
}

.auth-required p {
    color: #666;
    margin-bottom: 1.5rem;
}

/* Microsoft login button */
.btn-microsoft {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: #2f2f2f;
    color: white;
    padding: 0.875rem 1.5rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.2s ease;
    width: auto;
}

.btn-microsoft:hover {
    background: #1a1a1a;
}

.microsoft-icon {
    flex-shrink: 0;
}

/* Company Admin */
.company-admin-badge {
    display: inline-block;
    background: #27ae60;
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.view-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    width: fit-content;
}

.view-toggle-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #555;
    background: white;
    text-decoration: none;
    border-right: 1px solid #ddd;
    transition: all 0.15s ease;
}

.view-toggle-btn:last-child {
    border-right: none;
}

.view-toggle-btn:hover {
    background: #f5f5f5;
}

.view-toggle-btn.active {
    background: #4B9CD3;
    color: white;
}

.submitter-cell {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 1rem;
    color: #999;
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 480px) {
    .card {
        padding: 1.5rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .options-row {
        grid-template-columns: 1fr;
    }
}

/* User menu dropdown */
.user-menu {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 100;
}

.user-menu-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    transition: all 0.15s;
    padding: 0;
}

.user-menu-btn:hover {
    background: #f0f0f0;
    border-color: #bbb;
    color: #333;
}

.user-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 0.75rem 1rem;
    min-width: 220px;
    white-space: nowrap;
}

.user-menu-dropdown.open {
    display: block;
}

.umd-name {
    font-weight: 600;
    color: #1a1a2e;
    font-size: 0.9rem;
}

.umd-company {
    color: #888;
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

.umd-email {
    color: #666;
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

.umd-role {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #e74c3c;
    color: white;
}

.umd-role-super {
    background: #8b0000;
}

.umd-divider {
    border-top: 1px solid #eee;
    margin: 0.5rem -1rem;
}

.umd-link {
    display: block;
    color: #4B9CD3;
    font-size: 0.85rem;
    text-decoration: none;
    padding: 0.25rem 0;
    margin-top: 0.25rem;
}

.umd-link:hover {
    text-decoration: underline;
}

.umd-signout {
    display: block;
    color: #e74c3c;
    font-size: 0.85rem;
    text-decoration: none;
    padding: 0.25rem 0;
    margin-top: 0.25rem;
}

.umd-signout:hover {
    text-decoration: underline;
}

/* ===== Top Bar ===== */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 0;
}

body.has-impersonation-banner .top-bar {
    top: 36px;
}

.top-bar-logo {
    font-family: 'Times New Roman', Times, serif;
    font-size: 1.35rem;
    color: #1a1a2e;
    text-decoration: none;
    white-space: nowrap;
    margin-right: 2rem;
    flex-shrink: 0;
}

.top-bar-logo:hover {
    opacity: 0.8;
}

.top-bar-center {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 1;
    min-width: 0;
}

.top-bar-tab {
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 1rem;
    color: #555;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    white-space: nowrap;
}

.top-bar-tab:hover {
    color: #1a1a2e;
    background: #f3f4f6;
}

.top-bar-tab.active {
    color: #c0392b;
    font-weight: 600;
    border-bottom-color: #c0392b;
}

/* Top bar dropdowns */
.top-bar-dropdown {
    position: relative;
}

.top-bar-dropdown-trigger {
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 1rem;
    color: #555;
    font-size: 0.9rem;
    font-weight: 500;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    gap: 0.35rem;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}

.top-bar-dropdown-trigger:hover {
    color: #1a1a2e;
    background: #f3f4f6;
}

.top-bar-dropdown-trigger.active {
    color: #c0392b;
    font-weight: 600;
    border-bottom-color: #c0392b;
}

.dropdown-caret {
    font-size: 0.65rem;
    transition: transform 0.15s;
}

.top-bar-dropdown.open .dropdown-caret {
    transform: rotate(180deg);
}

.top-bar-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 0.5rem 0;
    min-width: 200px;
    z-index: 1001;
}

.top-bar-dropdown.open .top-bar-dropdown-menu {
    display: block;
}

.top-bar-dropdown-menu a {
    display: block;
    padding: 0.5rem 1rem;
    color: #333;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.1s;
}

.top-bar-dropdown-menu a:hover {
    background: #f3f4f6;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    flex-shrink: 0;
}

/* ===== NEW NAV: User Menu (inside top bar) ===== */
.tb-user-menu {
    position: relative;
}

.tb-user-menu-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    transition: all 0.15s;
    padding: 0;
}

.tb-user-menu-btn:hover {
    background: #f0f0f0;
    border-color: #bbb;
    color: #333;
}

.tb-user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 0.75rem 1rem;
    min-width: 240px;
    white-space: nowrap;
    z-index: 1001;
}

.tb-user-dropdown.open {
    display: block;
}

/* ===== NEW NAV: Impersonation Banner ===== */
.imp-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 36px;
    background: #dc2626;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    z-index: 1001;
}

.imp-banner-stop {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.6);
    color: #fff;
    padding: 0.15rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.imp-banner-stop:hover {
    background: rgba(255,255,255,0.15);
}

.imp-mode-badge {
    background: rgba(255,255,255,0.2);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* ===== NEW NAV: Platform Sidebar ===== */
.platform-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    transition: width 0.2s;
}

body.has-impersonation-banner .platform-sidebar {
    top: 92px;
    height: calc(100vh - 92px);
}

.platform-sidebar.collapsed {
    width: 56px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    color: #555;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.1s;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-item:hover {
    background: #f3f4f6;
    color: #1a1a2e;
}

.sidebar-item.active {
    border-left-color: #c0392b;
    background: #fef2f2;
    color: #c0392b;
    font-weight: 600;
}

.sidebar-item-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-right: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: inherit;
}

.platform-sidebar.collapsed .sidebar-item-label {
    display: none;
}

.platform-sidebar.collapsed .sidebar-item {
    padding: 0.6rem;
    justify-content: center;
}

.platform-sidebar.collapsed .sidebar-item-icon {
    margin-right: 0;
}

.sidebar-collapse-toggle {
    margin-top: auto;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    border-top: 1px solid #e5e7eb;
    color: #999;
    cursor: pointer;
    font-size: 0.8rem;
    text-align: left;
    transition: color 0.15s;
}

.sidebar-collapse-toggle:hover {
    color: #555;
}

/* ===== NEW NAV: Breadcrumbs ===== */
.breadcrumbs {
    padding: 0.75rem 0;
    font-size: 0.8rem;
    color: #6b7280;
}

.breadcrumbs a {
    color: #6b7280;
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: #374151;
    text-decoration: underline;
}

.bc-sep {
    margin: 0 0.4rem;
    color: #d1d5db;
}

.breadcrumbs [aria-current="page"] {
    color: #374151;
    font-weight: 500;
}

/* ===== NEW NAV: Layout ===== */
.app-body {
    display: flex;
    min-height: calc(100vh - 56px);
    padding-top: 56px;
}

body.has-impersonation-banner .app-body {
    min-height: calc(100vh - 92px);
    padding-top: 92px;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Content width classes */
.content-narrow {
    max-width: 640px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.content-medium {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.content-wide {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.content-extra-wide {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ===== NEW NAV: Responsive ===== */
@media (max-width: 1024px) {
    .platform-sidebar {
        width: 56px;
    }

    .platform-sidebar .sidebar-item-label {
        display: none;
    }

    .platform-sidebar .sidebar-item {
        padding: 0.6rem;
        justify-content: center;
    }

    .platform-sidebar .sidebar-item-icon {
        margin-right: 0;
    }
}

@media (max-width: 768px) {
    .top-bar {
        padding: 0 0.75rem;
    }

    .top-bar-logo {
        margin-right: 1rem;
        font-size: 1.15rem;
    }

    .top-bar-tab, .top-bar-dropdown-trigger {
        padding: 0 0.6rem;
        font-size: 0.8rem;
    }
}
