/* 
 * Lease Agreement Analyzer Styles
 * Theme: Dark Mode with Violet/Purple accents
 */

:root {
    --bg-main: #0F172A;
    /* Slate 900 */
    --bg-card: #1E293B;
    /* Slate 800 */
    --bg-elevated: #334155;
    /* Slate 700 */

    --primary: #8B5CF6;
    /* Violet 500 */
    --primary-hover: #7C3AED;
    --secondary: #A78BFA;
    --accent: #C4B5FD;

    --text-main: #F8FAFC;
    /* Slate 50 */
    --text-muted: #94A3B8;
    /* Slate 400 */
    --border: #334155;

    --danger: #EF4444;
    --warning: #F59E0B;
    --success: #10B981;

    --font-main: 'Inter', system-ui, sans-serif;

    --radius-xl: 16px;
    --radius-lg: 12px;
    --radius: 8px;

    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.15);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Utilities */
.hidden {
    display: none !important;
}

.text-primary {
    color: var(--primary);
}

.text-danger {
    color: var(--danger) !important;
}

.text-muted {
    color: var(--text-muted);
}

.text-sm {
    font-size: 0.875rem;
}

.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    display: inline-block;
}

.pt-4 {
    padding-top: 1.5rem;
}

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

.badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}

/* --- Navbar --- */
.navbar {
    height: 70px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 50;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), #4F46E5);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: var(--shadow-glow);
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.logo-text .badge {
    margin-left: 0;
    background: rgba(167, 139, 250, 0.1);
    color: var(--secondary);
    border: 1px solid rgba(167, 139, 250, 0.2);
}

.nav-actions {
    display: flex;
    gap: 1rem;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--text-main);
    border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
    background: var(--bg-card);
    border-color: var(--secondary);
}

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius);
    display: flex;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* --- Container --- */
.container {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* --- Upload Section --- */
.upload-section {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.upload-section:not(.active) {
    opacity: 0;
    pointer-events: none;
    z-index: -1;
}

.hero-text {
    text-align: center;
    max-width: 600px;
    margin-bottom: 2.5rem;
}

.hero-text h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.hero-text p {
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1.6;
}

.drop-zone {
    width: 100%;
    max-width: 600px;
    height: 250px;
    background: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.05);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.upload-content {
    text-align: center;
}

.upload-icon-wrapper {
    width: 64px;
    height: 64px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: var(--primary);
    font-size: 2rem;
}

.drop-zone:hover .upload-icon-wrapper {
    transform: scale(1.1);
    background: var(--primary);
    color: white;
    transition: all 0.3s ease;
}

.upload-content h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    max-width: 800px;
    margin-top: 3rem;
}

.feature-item {
    text-align: center;
    padding: 1.5rem;
    background: rgba(30, 41, 59, 0.5);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.feature-item i {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    display: block;
}

.feature-item h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.feature-item p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* --- Loading State --- */
.loading-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
    z-index: 20;
}

.spinner {
    width: 64px;
    height: 64px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 2rem;
}

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

.loading-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.progress-bar-container {
    width: 100%;
    max-width: 400px;
    height: 6px;
    background: var(--bg-card);
    border-radius: 4px;
    margin-top: 2rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: var(--shadow-glow);
}

/* --- Analysis Dashboard --- */
.analysis-dashboard {
    width: 100%;
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.panel-header {
    height: 60px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

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

.panel-body {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.scroll-y {
    overflow-y: auto;
    padding: 1.5rem;
}

/* Doc Viewer pane */
.doc-panel {
    flex: 1.5;
}

.doc-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.text-layer {
    padding: 2rem;
    font-family: inherit;
    line-height: 1.8;
    color: #cbd5e1;
    font-size: 0.95rem;
    white-space: pre-wrap;
    height: 100%;
    overflow-y: auto;
}

/* Document Highlights */
.hl {
    background: rgba(139, 92, 246, 0.2);
    color: var(--accent);
    padding: 0.1rem 0;
    border-radius: 2px;
    border-bottom: 1px dashed var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}

.hl:hover {
    background: rgba(139, 92, 246, 0.4);
}

.hl-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border-bottom: 1px dashed var(--danger);
}

.hl-danger:hover {
    background: rgba(239, 68, 68, 0.4);
}

/* Results Pane */
.results-panel {
    flex: 1;
    min-width: 400px;
    border-left: 1px solid var(--border);
}

/* Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.metric-card {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.metric-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-val {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.risk-card.high .metric-val {
    color: var(--danger);
}

.risk-card.medium .metric-val {
    color: var(--warning);
}

.risk-card.low .metric-val {
    color: var(--success);
}

/* Reports */
.section-title {
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.item-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.report-item {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    border-left: 3px solid var(--primary);
}

.report-item.danger {
    border-left-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

.report-item-title {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.report-item-title .tag {
    font-size: 0.7rem;
    background: var(--border);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.report-item-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.key-terms-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.term-box {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
}

.term-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.term-value {
    font-size: 0.9rem;
    font-weight: 600;
}

.empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* Responsive */
@media (max-width: 1024px) {
    .analysis-dashboard {
        flex-direction: column;
    }

    .results-panel {
        min-height: 600px;
    }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translate(-50%, 100px);
    background: var(--bg-card);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    border: 1px solid var(--primary);
    font-size: 0.875rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.toast.error {
    border-color: var(--danger);
    color: #fca5a5;
}

.toast.show {
    transform: translate(-50%, 0);
    opacity: 1;
}