/**
 * Resume Tailor AI Page Styles
 * Premium, intelligent, trust-driven design for senior professionals
 */

/* ==================== BASE ==================== */
.hi-resume-tailor {
    background: var(--color-bg-primary);
    min-height: 100vh;
    padding-top: 88px;
}

.hrt-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.hrt-container--wide {
    max-width: 1400px;
}

/* ==================== HERO SECTION ==================== */
.hrt-hero {
    padding: 60px 0 48px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border-primary);
    position: relative;
}

.hrt-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 20%, var(--glow-purple), transparent 60%),
                radial-gradient(circle at 70% 80%, var(--glow-cyan), transparent 60%);
    opacity: 0.3;
    pointer-events: none;
}

.hrt-hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.hrt-hero-title {
    font-size: clamp(32px, 4vw, 56px);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0 0 20px;
    color: var(--color-text-primary);
}

.hrt-hero-subtitle {
    font-size: clamp(16px, 2vw, 20px);
    line-height: 1.6;
    color: var(--color-text-muted);
    margin: 0;
    max-width: 700px;
    margin: 0 auto;
}

/* ==================== INPUT SECTION ==================== */
.hrt-input-section {
    padding: 60px 0;
}

.hrt-form {
    width: 100%;
}

.hrt-input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 40px;
}

.hrt-input-block {
    background: var(--color-surface);
    border: 1px solid var(--color-border-primary);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.hrt-input-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-accent-cyan), var(--color-accent-purple));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.hrt-input-block:hover {
    border-color: var(--color-border-hover);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.hrt-input-block:hover::before {
    opacity: 1;
}

.hrt-input-block:focus-within {
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px var(--glow-cyan), var(--shadow-lg);
}

.hrt-input-block:focus-within::before {
    opacity: 1;
}

.hrt-block-header {
    margin-bottom: 20px;
}

.hrt-block-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0 0 16px;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hrt-block-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: linear-gradient(135deg, var(--color-accent-cyan), var(--color-accent-purple));
    border-radius: 2px;
}

/* ==================== TABS ==================== */
.hrt-tabs {
    display: flex;
    gap: 8px;
    background: var(--color-bg-secondary);
    padding: 4px;
    border-radius: var(--radius-md);
}

.hrt-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--theme-transition);
}

.hrt-tab:hover {
    background: var(--color-surface-hover);
    color: var(--color-text-primary);
}

.hrt-tab--active {
    background: var(--color-surface);
    color: var(--color-text-primary);
    box-shadow: var(--shadow-sm);
}

/* ==================== TAB CONTENT ==================== */
.hrt-tab-content {
    display: none;
}

.hrt-tab-content--active {
    display: block;
}

/* ==================== FORM INPUTS ==================== */
.hrt-textarea,
.hrt-input {
    width: 100%;
    padding: 16px;
    border: 1.5px solid var(--color-border-primary);
    border-radius: var(--radius-md);
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    font-family: var(--font-body, 'Poppins', 'Inter', system-ui, sans-serif);
    font-size: 15px;
    line-height: 1.6;
    resize: vertical;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.hrt-textarea:hover,
.hrt-input:hover {
    border-color: var(--color-border-hover);
    background: var(--color-surface);
}

.hrt-textarea:focus,
.hrt-input:focus {
    outline: none;
    border-color: var(--color-accent-cyan);
    background: var(--color-surface);
    box-shadow: 0 0 0 3px var(--glow-cyan);
    transform: translateY(-1px);
}

.hrt-textarea::placeholder,
.hrt-input::placeholder {
    color: var(--color-text-disabled);
}

.hrt-helper {
    margin: 12px 0 0;
    font-size: 13px;
    color: var(--color-text-muted);
    line-height: 1.5;
}

/* ==================== CTA SECTION ==================== */
.hrt-cta-wrapper {
    text-align: center;
    padding: 32px 0;
}

.hrt-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 18px 40px;
    border: none;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--color-accent-purple), var(--color-accent-cyan));
    color: var(--color-text-inverse);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(168, 85, 247, 0.3), 0 4px 12px rgba(56, 189, 248, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.hrt-btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.hrt-btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(168, 85, 247, 0.4), 0 6px 16px rgba(56, 189, 248, 0.3);
}

.hrt-btn-primary:hover::before {
    left: 100%;
}

.hrt-btn-primary:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.35), 0 3px 10px rgba(56, 189, 248, 0.25);
}

.hrt-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: var(--shadow-md);
}

.hrt-btn-primary:disabled::before {
    display: none;
}

.hrt-btn-icon {
    transition: transform 0.3s ease;
}

.hrt-btn-primary:hover .hrt-btn-icon {
    transform: translateX(4px);
}

.hrt-cta-note {
    margin: 16px 0 0;
    font-size: 13px;
    color: var(--color-text-muted);
}

/* ==================== LOADING STATES ==================== */
.hrt-loading {
    margin-top: 40px;
    padding: 40px;
    background: var(--color-surface);
    border: 1px solid var(--color-border-primary);
    border-radius: var(--radius-lg);
    text-align: center;
}

.hrt-loading-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 32px;
    border: 4px solid var(--color-border-primary);
    border-top-color: var(--color-accent-cyan);
    border-right-color: var(--color-accent-purple);
    border-radius: 50%;
    animation: hrt-spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

@keyframes hrt-spin {
    to { transform: rotate(360deg); }
}

.hrt-loading-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 400px;
    margin: 0 auto;
}

.hrt-loading-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    font-size: 15px;
    font-weight: 500;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.hrt-loading-step--active {
    opacity: 1;
    color: var(--color-text-primary);
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border-hover);
    box-shadow: var(--shadow-glow-cyan);
}

.hrt-step-icon {
    width: 20px;
    height: 20px;
    color: var(--color-accent-cyan);
}

.hrt-loading-step--active .hrt-step-icon svg {
    animation: hrt-pulse 1.5s ease-in-out infinite;
}

@keyframes hrt-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==================== EDITOR SECTION ==================== */
.hrt-editor-section {
    padding: 60px 0 80px;
    background: var(--color-bg-secondary);
}

.hrt-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    gap: 24px;
}

.hrt-editor-header-content {
    flex: 1;
}

.hrt-editor-title {
    font-size: clamp(24px, 3vw, 32px);
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0 0 8px;
}

.hrt-editor-subtitle {
    font-size: 15px;
    color: var(--color-text-muted);
    margin: 0;
}

.hrt-success-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: var(--glow-green);
    border: 1px solid var(--color-accent-green);
    border-radius: var(--radius-full);
    color: var(--color-accent-green);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    animation: hrt-badge-appear 0.4s ease-out;
}

@keyframes hrt-badge-appear {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.hrt-editor-wrapper {
    background: var(--color-surface);
    border: 1px solid var(--color-border-primary);
    border-radius: 16px;
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04),
        0 24px 80px rgba(0, 0, 0, 0.25),
        0 8px 32px rgba(0, 0, 0, 0.15);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    height: 82vh;
    min-height: 550px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.hrt-editor-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--color-accent-cyan), var(--color-accent-purple), var(--color-accent-cyan));
    background-size: 200% 100%;
    animation: hrt-gradient-shift 4s ease infinite;
    z-index: 10;
}

@keyframes hrt-gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.hrt-editor-wrapper:hover {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.06),
        0 28px 90px rgba(0, 0, 0, 0.3),
        0 10px 36px rgba(0, 0, 0, 0.18),
        0 0 40px rgba(0, 210, 255, 0.04);
}

.hrt-editor-missing {
    padding: 60px 40px;
    text-align: center;
}

.hrt-editor-missing h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0 0 12px;
}

.hrt-editor-missing p {
    font-size: 16px;
    color: var(--color-text-muted);
    margin: 0;
}

/* ==================== HILATEX INTEGRATION — IDE DESIGN ==================== */
.hrt-editor-wrapper .hilatex-container {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: auto 1fr !important;
    gap: 0 !important;
    margin: 0 !important;
    flex: 1 !important;
    min-height: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
}

/* ── Toolbar ── */
.hrt-editor-wrapper .hilatex-actions {
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 10px 20px !important;
    border-bottom: 1px solid var(--color-border-primary) !important;
    background: linear-gradient(180deg, var(--color-surface-elevated, var(--color-surface)) 0%, var(--color-surface) 100%) !important;
    order: -1 !important;
    visibility: visible !important;
    position: relative !important;
}

.hrt-editor-wrapper .hilatex-actions::after {
    content: 'HiLaTeX Editor';
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    opacity: 0.5;
    pointer-events: none;
}

/* ── Toolbar Buttons ── */
.hrt-editor-wrapper .hilatex-actions button {
    border: none !important;
    border-radius: 8px !important;
    padding: 9px 18px !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    cursor: pointer !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative !important;
    overflow: hidden !important;
    letter-spacing: 0.01em !important;
}

.hrt-editor-wrapper .hilatex-actions button::before {
    content: '' !important;
    position: absolute !important;
    inset: 0 !important;
    opacity: 0 !important;
    transition: opacity 0.25s ease !important;
    border-radius: inherit !important;
}

/* Compile button — cyan accent */
.hrt-editor-wrapper .hilatex-compile {
    background: linear-gradient(135deg, #0ea5e9, #06b6d4) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3), inset 0 1px 0 rgba(255,255,255,0.15) !important;
}

.hrt-editor-wrapper .hilatex-compile:hover {
    background: linear-gradient(135deg, #0284c7, #0891b2) !important;
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.4), inset 0 1px 0 rgba(255,255,255,0.2) !important;
    transform: translateY(-1px) !important;
}

.hrt-editor-wrapper .hilatex-compile:active {
    transform: translateY(0) !important;
    box-shadow: 0 1px 4px rgba(14, 165, 233, 0.3) !important;
}

/* Download button — green accent */
.hrt-editor-wrapper .hilatex-download {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3), inset 0 1px 0 rgba(255,255,255,0.15) !important;
}

.hrt-editor-wrapper .hilatex-download:hover {
    background: linear-gradient(135deg, #059669, #047857) !important;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4), inset 0 1px 0 rgba(255,255,255,0.2) !important;
    transform: translateY(-1px) !important;
}

.hrt-editor-wrapper .hilatex-download:active {
    transform: translateY(0) !important;
    box-shadow: 0 1px 4px rgba(16, 185, 129, 0.3) !important;
}

/* Clear button — subtle ghost */
.hrt-editor-wrapper .hilatex-clear {
    background: transparent !important;
    color: var(--color-text-muted) !important;
    border: 1px solid var(--color-border-primary) !important;
    box-shadow: none !important;
}

.hrt-editor-wrapper .hilatex-clear:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #f87171 !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
    transform: translateY(-1px) !important;
}

/* ── Editor Panel ── */
.hrt-editor-wrapper .hilatex-editor {
    height: 100% !important;
    min-height: 0 !important;
    border: none !important;
    border-right: 1px solid var(--color-border-primary) !important;
    grid-row: 2 !important;
    grid-column: 1 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    overflow: hidden !important;
}

.hrt-editor-wrapper #hilatex-editor {
    min-height: 100% !important;
    height: 100% !important;
}

/* ── Preview Panel ── */
.hrt-editor-wrapper .hilatex-preview-wrapper {
    background-color: #e8e8e8 !important;
    padding: 16px !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
    grid-row: 2 !important;
    grid-column: 2 !important;
    min-height: 0 !important;
    height: 100% !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
}

.hrt-editor-wrapper .hilatex-preview-wrapper::before {
    content: 'PREVIEW';
    position: absolute;
    top: 10px;
    right: 16px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--color-text-muted);
    opacity: 0.35;
    pointer-events: none;
    z-index: 1;
}

/* ── Preview Paper — scale A4 to fit panel ── */
.hrt-editor-wrapper #hilatex-preview {
    color: #1a1a1a !important;
    position: relative !important;
    min-height: 100px !important;
    transform-origin: top left !important;
}

.hrt-editor-wrapper #hilatex-preview .hilatex-rendered {
    color: #1a1a1a !important;
}

.hrt-editor-wrapper #hilatex-preview .ltx-page {
    border-radius: 3px !important;
    box-shadow:
        0 1px 4px rgba(0,0,0,0.1),
        0 4px 16px rgba(0,0,0,0.12) !important;
    margin: 0 auto 20px !important;
}

/* ── Compile Spinner ── */
.hilatex-compile-spinner {
    width: 36px;
    height: 36px;
    margin: 0 auto;
    border: 3px solid rgba(148, 163, 184, 0.2);
    border-top-color: #0ea5e9;
    border-radius: 50%;
    animation: hilatex-spin 0.8s linear infinite;
}

.hilatex-btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: hilatex-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes hilatex-spin {
    to { transform: rotate(360deg); }
}

.hrt-editor-wrapper .hilatex-compile:disabled {
    opacity: 0.7 !important;
    cursor: wait !important;
    transform: none !important;
}

/* ── Compilation Error Styling ── */
.hrt-editor-wrapper #hilatex-preview > div[style*="color: #d32f2f"],
.hrt-editor-wrapper #hilatex-preview > div[style*="color:#d32f2f"] {
    border-radius: 12px !important;
    font-size: 14px !important;
}

/* ==================== RESUME INPUT ==================== */
.hrt-resume-input {
    display: block;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .hrt-input-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .hrt-editor-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .hrt-editor-wrapper {
        height: auto !important;
        max-height: none !important;
        min-height: auto !important;
    }

    .hrt-editor-wrapper .hilatex-container {
        grid-template-columns: 1fr !important;
    }

    .hrt-editor-wrapper .hilatex-editor {
        border-right: none !important;
        border-bottom: 1px solid var(--color-border-primary) !important;
        min-height: 400px !important;
        height: 400px !important;
        grid-column: 1 !important;
    }

    .hrt-editor-wrapper #hilatex-editor {
        min-height: 400px !important;
        height: 400px !important;
    }

    .hrt-editor-wrapper .hilatex-preview-wrapper {
        grid-column: 1 !important;
        min-height: 500px !important;
        max-height: 80vh !important;
    }

    .hrt-editor-wrapper .hilatex-preview-wrapper::before {
        display: none;
    }

    /* .ltx-page dimensions handled by JS pagination + scalePreviewToFit */

    .hrt-editor-wrapper .hilatex-actions::after {
        display: none;
    }
}

@media (max-width: 768px) {
    .hi-resume-tailor {
        padding-top: 72px;
    }

    .hrt-hero {
        padding: 40px 0 32px;
    }

    .hrt-input-section {
        padding: 40px 0;
    }

    .hrt-input-block {
        padding: 20px;
    }

    .hrt-tabs {
        flex-direction: column;
    }

    .hrt-btn-primary {
        width: 100%;
        justify-content: center;
        padding: 16px 32px;
    }

    .hrt-loading {
        padding: 32px 20px;
    }

    .hrt-editor-section {
        padding: 40px 0 60px;
    }

    .hrt-editor-title {
        font-size: 22px;
    }

    .hrt-editor-subtitle {
        font-size: 14px;
    }

    .hrt-editor-wrapper .hilatex-actions {
        padding: 8px 12px !important;
        gap: 6px !important;
        flex-wrap: wrap !important;
    }

    .hrt-editor-wrapper .hilatex-actions button {
        padding: 7px 14px !important;
        font-size: 12px !important;
    }

    /* .ltx-page dimensions handled by JS pagination + scalePreviewToFit */
}

@media (max-width: 480px) {
    .hrt-container {
        padding: 0 16px;
    }

    .hrt-hero-title {
        font-size: 28px;
    }

    .hrt-hero-subtitle {
        font-size: 16px;
    }

    .hrt-input-block {
        padding: 16px;
    }

    .hrt-block-title {
        font-size: 18px;
    }
}
