/* ============================================
   TurtoDoc - Clean, Minimal SaaS Design
   ============================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #334155;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #f8fafc;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.04), 0 2px 4px rgba(0,0,0,0.06);
    --transition: 0.2s ease;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

/* Prevent white flash during page transitions */
html {
    background: var(--bg);
}

html, body {
    min-height: 100vh;
}

/* ---- App Layout ---- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

/* Sidebar backdrop for mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

@media (max-width: 767px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .sidebar-backdrop.show {
        display: block;
    }
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px 20px;
}

.brand-logo {
    height: 36px;
    width: auto;
    object-fit: contain;
}

.brand-text {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
}

.sidebar-nav .nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.sidebar-nav .nav-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
}

.sidebar-nav .nav-item i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 500;
}

.user-role {
    color: var(--sidebar-text);
    font-size: 11px;
}

.logout-btn {
    font-size: 13px !important;
    padding: 8px 14px !important;
    opacity: 0.7;
}

.logout-btn:hover {
    opacity: 1;
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

@media (max-width: 767px) {
    .main-content {
        margin-left: 0;
    }
}

/* ---- Top Bar ---- */
.topbar {
    display: flex;
    align-items: center;
    padding: 16px 32px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    gap: 16px;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text);
    cursor: pointer;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.3px;
}

.topbar-actions {
    margin-left: auto;
}

/* ---- Page Content ---- */
.page-content {
    padding: 24px 32px;
    flex: 1;
}

@media (max-width: 767px) {
    .topbar { padding: 12px 16px; }
    .page-content { padding: 16px; }
}

/* ---- Stat Cards ---- */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: all var(--transition);
}

.stat-card.action-card {
    cursor: pointer;
}

.stat-card.action-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    display: block;
}

/* ---- Content Cards ---- */
.content-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.content-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.content-card-header h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

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

/* ---- Tables ---- */
.table thead th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
}

.table tbody td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: #f8fafc;
}

/* ---- Empty States ---- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state i {
    font-size: 48px;
    color: #cbd5e1;
    display: block;
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ---- Client Avatar ---- */
.client-avatar {
    width: 32px;
    height: 32px;
    background: #e0f2fe;
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

/* ---- Upload Zone ---- */
.upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    transition: all var(--transition);
    background: #fafbfc;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--primary);
    background: #eff6ff;
}

.upload-icon {
    font-size: 48px;
    color: #94a3b8;
    margin-bottom: 12px;
}

.upload-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

.upload-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

/* ---- Scanning Animation ---- */
.scanning-animation {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.document-icon {
    position: relative;
    font-size: 80px;
    color: var(--primary);
    margin-bottom: 20px;
    overflow: hidden;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #3b82f6, transparent);
    animation: scanning 2s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

@keyframes scanning {
    0% {
        transform: translateY(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(80px);
        opacity: 0;
    }
}

.progress-container {
    width: 100%;
    max-width: 400px;
}

.scan-status {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    text-align: center;
    margin: 0;
}

.upload-success i {
    font-size: 40px;
    display: block;
    margin-bottom: 8px;
}

.upload-success p {
    color: #16a34a;
    font-weight: 500;
}

/* ---- Forms ---- */
.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

.form-control, .form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    font-size: 14px;
    transition: all var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

textarea.form-control {
    resize: vertical;
}

/* Highlight animation for scanned fields */
@keyframes fieldFill {
    0% { background-color: #dbeafe; }
    100% { background-color: #fff; }
}

.field-filled {
    animation: fieldFill 2s ease;
}

/* ---- Buttons ---- */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 14px;
}

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

.btn-light {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: var(--text);
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.btn-outline-primary {
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.btn-outline-secondary, .btn-outline-danger {
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 11px 24px;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}

/* ---- Alerts ---- */
.alert {
    border-radius: var(--radius-sm);
    font-size: 14px;
    border: none;
}

.alert-sm {
    padding: 10px 14px;
    font-size: 13px;
}

/* ---- Badge ---- */
.badge {
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 13px;
}

/* ============================================
   Auth Pages
   ============================================ */
.auth-body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-bg);
    position: relative;
    overflow: hidden;
}

html:has(.auth-body) {
    background: var(--sidebar-bg);
}

.auth-body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, transparent 70%);
    animation: pulse 15s ease-in-out infinite;
    pointer-events: none;
}

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

.auth-logos-bottom {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10;
}

.auth-logos-bottom img {
    height: 45px;
    width: auto;
    opacity: 0.9;
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 24px;
    position: relative;
    z-index: 1;
}

@media (max-width: 480px) {
    .auth-container {
        padding: 16px;
    }
    .auth-card {
        padding: 28px 20px;
        border-radius: 12px;
    }
    .auth-logos-bottom {
        bottom: 12px;
        right: 12px;
        gap: 10px;
    }
    .auth-logos-bottom img {
        height: 32px;
    }
}

.auth-card {
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo-img {
    width: 120px;
    height: auto;
    margin: 0 auto 16px;
    display: flex;
    justify-content: center;
}

.auth-logo-img img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.auth-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 4px;
    letter-spacing: -0.3px;
    color: #f8fafc;
}

.auth-header p {
    color: #94a3b8;
    font-size: 14px;
    margin: 0;
}

.auth-card .form-label {
    font-size: 13px;
    font-weight: 500;
    color: #e2e8f0;
}

.auth-card .form-control {
    background: rgba(30, 58, 138, 0.6) !important;
    border-color: rgba(59, 130, 246, 0.3);
    color: #ffffff !important;
}

.auth-card .form-control:focus {
    background: rgba(30, 58, 138, 0.8) !important;
    border-color: var(--primary);
    color: #ffffff !important;
}

.auth-card .form-control::placeholder {
    color: rgba(226, 232, 240, 0.5);
}

/* Prevent browser autofill from changing colors */
.auth-card .form-control:-webkit-autofill,
.auth-card .form-control:-webkit-autofill:hover,
.auth-card .form-control:-webkit-autofill:focus,
.auth-card .form-control:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px rgba(30, 58, 138, 0.8) inset !important;
    -webkit-text-fill-color: #ffffff !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
}

/* Also handle when input has value */
.auth-card .form-control:not(:placeholder-shown) {
    background: rgba(30, 58, 138, 0.8) !important;
    color: #ffffff !important;
}

.auth-card .input-group-text {
    background: rgba(30, 58, 138, 0.6);
    border-color: rgba(59, 130, 246, 0.3);
    color: #e2e8f0;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: #94a3b8;
}

.auth-footer a {
    color: #60a5fa;
    text-decoration: none;
    font-weight: 500;
    margin-left: 4px;
}

.auth-footer a:hover {
    text-decoration: underline;
    color: var(--primary);
}

/* ---- Partner Logos ---- */
.partner-logos {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
    padding: 20px 0;
    margin-top: auto;
    opacity: 0.4;
    transition: opacity var(--transition);
}

.partner-logos:hover {
    opacity: 0.7;
}

.partner-logo {
    height: 32px;
    width: auto;
    object-fit: contain;
    filter: grayscale(100%);
}

/* ---- Auth: Forgot Password Link ---- */
.auth-forgot-link {
    color: #fbbf24;
    font-size: 13px;
    text-decoration: none;
    transition: color 0.2s;
}

.auth-forgot-link:hover {
    color: #f59e0b;
    text-decoration: underline;
}

/* ---- Auth: Divider ---- */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    gap: 12px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(148, 163, 184, 0.2);
}

.auth-divider span {
    color: #94a3b8;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Auth: Google Button ---- */
.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #3c4043;
    border: 1px solid #dadce0;
    font-weight: 500;
    font-size: 15px;
    padding: 10px 16px;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-google:hover {
    background: #f8f9fa;
    color: #3c4043;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ---- Generate Overlay ---- */
.generate-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.generate-overlay.active {
    opacity: 1;
    visibility: visible;
}

.generate-popup {
    background: #ffffff;
    border-radius: 20px;
    padding: 48px 56px;
    text-align: center;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    max-width: 420px;
    width: 90%;
    animation: popupSlideUp 0.4s ease-out;
}

@keyframes popupSlideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.generate-popup-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    position: relative;
}

.generate-popup-icon i {
    font-size: 32px;
    color: #ffffff;
    animation: docPulse 1.5s ease-in-out infinite;
}

@keyframes docPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.generate-popup-icon::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid #3b82f6;
    animation: ringExpand 1.5s ease-out infinite;
}

@keyframes ringExpand {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

.generate-popup h3 {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 8px;
}

.generate-popup p {
    font-size: 14px;
    color: #64748b;
    margin: 0 0 24px;
}

.generate-progress {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.generate-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #6366f1, #3b82f6);
    background-size: 200% 100%;
    border-radius: 3px;
    animation: progressShimmer 1.5s linear infinite;
    width: 100%;
}

@keyframes progressShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   Onboarding Tour
   ============================================ */

/* Blur page content when onboarding is active */
.app-wrapper.onboard-blurred {
    filter: blur(2px);
    transition: filter 0.3s ease;
}

.onboard-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    background: transparent;
    transition: opacity 0.3s ease;
}
.onboard-overlay.active {
    display: block;
    animation: onboardFadeIn 0.3s ease;
}
@keyframes onboardFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.onboard-spotlight {
    position: absolute;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.65),
                0 0 30px rgba(99, 102, 241, 0.25);
    background: transparent;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10001;
    pointer-events: none;
}

.onboard-tooltip {
    display: none;
    position: absolute;
    z-index: 10003;
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    min-width: 320px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15),
                0 0 0 1px rgba(99, 102, 241, 0.1);
    animation: onboardTooltipIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: 'Inter', sans-serif;
}
@keyframes onboardTooltipIn {
    from { opacity: 0; transform: translateY(10px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.onboard-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.onboard-step-counter {
    font-size: 12px;
    font-weight: 600;
    color: #6366f1;
    background: #eef2ff;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.5px;
}
.onboard-close {
    background: none;
    border: none;
    font-size: 22px;
    color: #94a3b8;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}
.onboard-close:hover {
    color: #475569;
}

.onboard-title {
    font-size: 17px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 8px 0;
}
.onboard-body {
    font-size: 14px;
    line-height: 1.6;
    color: #475569;
    margin: 0 0 20px 0;
}

.onboard-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.onboard-actions-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.onboard-btn {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: 'Inter', sans-serif;
}
.onboard-btn-next {
    background: #6366f1;
    color: #fff;
}
.onboard-btn-next:hover {
    background: #4f46e5;
    transform: translateY(-1px);
}
.onboard-btn-back {
    background: #f1f5f9;
    color: #475569;
}
.onboard-btn-back:hover {
    background: #e2e8f0;
}
.onboard-btn-skip {
    background: none;
    color: #94a3b8;
    padding: 8px 12px;
}
.onboard-btn-skip:hover {
    color: #64748b;
}

.onboard-interactive-hint {
    font-size: 12px;
    color: #6366f1;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    animation: onboardPulse 2s ease-in-out infinite;
}
@keyframes onboardPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
