/* ============================================================================
   MarketMotor — Professional B2B Design
   Navy + Amber Color Scheme
   ============================================================================ */

:root {
    /* Brand Colors */
    --navy: #1B2A4A;
    --navy-light: #2C3E5F;
    --navy-dark: #0F1729;
    --amber: #F7B731;
    --amber-light: #FFC851;
    --amber-dark: #E8A626;
    
    /* Status Colors */
    --tier-blue: #3b82f6;
    --tier-green: #10b981;
    --tier-yellow: #f59e0b;
    --tier-red: #ef4444;
    
    /* Neutrals */
    --bg: #F5F7FA;
    --card-bg: #ffffff;
    --border: #E1E8ED;
    --text: #1B2A4A;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    
    /* UI */
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(27, 42, 74, 0.08);
    --shadow-md: 0 4px 6px rgba(27, 42, 74, 0.1);
    --shadow-lg: 0 10px 20px rgba(27, 42, 74, 0.12);
    
    /* Transitions */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    padding-top: 70px; /* Space for fixed nav */
}

/* ============================================================================
   Navigation Bar
   ============================================================================ */

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--navy);
    height: 70px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
}

.navbar-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: white;
}

.navbar-icon {
    font-size: 1.75rem;
}

.navbar-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.navbar-placeholder {
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
}

.navbar-user {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-tier {
    background: var(--amber);
    color: var(--navy);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.btn-nav {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.1);
}

.btn-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-nav-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-nav-outline:hover {
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.1);
}

/* ============================================================================
   Auth Pages
   ============================================================================ */

.auth-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 70vh;
    padding-top: 3rem;
}

.auth-card {
    max-width: 440px;
    width: 100%;
}

.auth-card h2 {
    text-align: center;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 1.5rem;
    margin-top: -0.5rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-light);
    font-size: 0.875rem;
}

.auth-footer a {
    color: var(--amber-dark);
    font-weight: 600;
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Flash Messages */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--tier-red);
}

.flash-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--tier-green);
}

/* Tier Info on Register */
.tier-info-box {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.tier-info-box h4 {
    font-size: 0.875rem;
    color: var(--navy);
    margin-bottom: 0.5rem;
}

.tier-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.tier-item {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ============================================================================
   Usage Banner
   ============================================================================ */

.usage-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--navy-light);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.usage-banner-count {
    color: var(--amber);
    font-weight: 600;
}

.usage-after-valuation {
    text-align: center;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-light);
    font-weight: 500;
}

/* ============================================================================
   Dashboard Stats
   ============================================================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    text-align: center;
    padding: 1.25rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--navy);
}

.stat-value-sm {
    font-size: 1.25rem;
}

.stat-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.tier-badge-inline {
    font-size: 1.5rem !important;
}

.tier-badge-inline.tier-free { color: var(--text-light); }
.tier-badge-inline.tier-pro { color: var(--amber-dark); }
.tier-badge-inline.tier-enterprise { color: var(--tier-blue); }

/* Usage Bar */
.usage-bar-container {
    margin-top: 0.5rem;
}

.usage-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    background: var(--amber);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.usage-bar-full {
    background: var(--tier-red);
}

.usage-bar-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

/* Tier Dots */
.tier-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.25rem;
    vertical-align: middle;
}

.tier-dot-blue { background: var(--tier-blue); }
.tier-dot-green { background: var(--tier-green); }
.tier-dot-yellow { background: var(--tier-yellow); }
.tier-dot-red { background: var(--tier-red); }

/* ============================================================================
   Tier Comparison (Dashboard)
   ============================================================================ */

.tier-comparison {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.tier-plan {
    padding: 1.5rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 2px solid var(--border);
    text-align: center;
    position: relative;
    transition: var(--transition);
}

.tier-plan-active {
    border-color: var(--amber);
    background: rgba(247, 183, 49, 0.05);
}

.tier-plan h3 {
    font-size: 1.25rem;
    color: var(--navy);
    margin-bottom: 0.5rem;
}

.tier-plan-price {
    font-size: 2rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 1rem;
}

.tier-plan-price span {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-light);
}

.tier-plan ul {
    list-style: none;
    text-align: left;
    font-size: 0.875rem;
    color: var(--text-light);
}

.tier-plan li {
    padding: 0.35rem 0;
}

.tier-plan li::before {
    content: '✓ ';
    color: var(--tier-green);
    font-weight: bold;
}

.tier-plan-badge {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.35rem 1rem;
    background: var(--amber);
    color: var(--navy);
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* ============================================================================
   Container
   ============================================================================ */

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* ============================================================================
   Header
   ============================================================================ */

header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.5s ease-out;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 0.5rem;
}

.tagline {
    font-size: 1.125rem;
    color: var(--text-light);
}

/* ============================================================================
   Cards
   ============================================================================ */

.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--navy);
}

/* ============================================================================
   Recent Searches Section
   ============================================================================ */

#recentSearches {
    margin-bottom: 2rem;
}

#recentSearches h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 1rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.history-item:hover {
    border-color: var(--amber);
    background: white;
    transform: translateX(4px);
}

.history-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.history-info strong {
    color: var(--navy);
    font-size: 1rem;
}

.history-info span {
    color: var(--text-light);
    font-size: 0.875rem;
}

.history-load-btn {
    padding: 0.5rem 1.25rem;
    background: var(--amber);
    color: var(--navy);
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.history-load-btn:hover {
    background: var(--amber-dark);
    transform: scale(1.05);
}

.history-clear-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.history-clear-btn:hover {
    border-color: var(--tier-red);
    color: var(--tier-red);
}

.no-history {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

/* ============================================================================
   Form
   ============================================================================ */

.form-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg);
    border-radius: var(--radius);
    border-left: 4px solid var(--amber);
}

.form-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    position: relative;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 0.5rem;
}

input, select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
    background: white;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--amber);
    box-shadow: 0 0 0 3px rgba(247, 183, 49, 0.1);
}

input::placeholder {
    color: var(--text-muted);
}

/* ============================================================================
   Autocomplete
   ============================================================================ */

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: white;
    border: 2px solid var(--amber);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 250px;
    overflow-y: auto;
    display: none;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: var(--bg);
    color: var(--navy);
    font-weight: 600;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn-primary {
    width: 100%;
    padding: 1rem 2rem;
    background: var(--amber);
    color: var(--navy);
    border: none;
    border-radius: var(--radius);
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    background: var(--amber-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

/* ============================================================================
   Results
   ============================================================================ */

.results {
    animation: fadeInUp 0.4s ease-out;
}

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

@keyframes fadeInDown {
    from { 
        opacity: 0; 
        transform: translateY(-20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.info-section {
    margin-bottom: 2rem;
}

.info-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--navy);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg);
    border-radius: var(--radius);
}

.info-grid div {
    font-size: 0.875rem;
}

.info-grid strong {
    color: var(--text-light);
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

/* ============================================================================
   Pricing Grid
   ============================================================================ */

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.pricing-item {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background: var(--bg);
    border-radius: var(--radius);
    text-align: center;
    border: 2px solid transparent;
    transition: var(--transition);
}

.pricing-item:hover {
    border-color: var(--amber);
    transform: translateY(-2px);
}

.pricing-item .label {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.pricing-item .value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--navy);
}

/* ============================================================================
   Price Range Visualization
   ============================================================================ */

#priceRangeSection {
    margin-top: 2rem;
    padding: 2rem;
    background: var(--bg);
    border-radius: var(--radius);
}

.price-range-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-light);
    font-weight: 600;
}

.price-range-normal {
    color: var(--navy);
    font-weight: 700;
}

.price-range-bar {
    position: relative;
    height: 40px;
    background: linear-gradient(to right, 
        var(--tier-blue) 0%, 
        var(--tier-green) 35%, 
        var(--tier-yellow) 65%, 
        var(--tier-red) 100%);
    border-radius: var(--radius);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.price-range-marker {
    position: absolute;
    top: -10px;
    width: 4px;
    height: 60px;
    background: var(--navy);
    transform: translateX(-50%);
    border-radius: 2px;
    box-shadow: var(--shadow-md);
}

.price-range-marker::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: inherit;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: var(--shadow-md);
}

.price-range-marker-label {
    position: absolute;
    top: -45px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    background: var(--navy);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    text-align: center;
    line-height: 1.3;
}

.price-range-marker-label::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--navy);
}

/* ============================================================================
   Tier Classification
   ============================================================================ */

.tier-section {
    text-align: center;
    padding: 2rem;
    background: var(--bg);
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    animation: pulse 0.5s ease-out;
}

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

.tier-badge {
    display: inline-block;
    padding: 1rem 2.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    transition: var(--transition);
}

.tier-badge.tier-blue {
    background: rgba(59, 130, 246, 0.1);
    color: var(--tier-blue);
    border: 3px solid var(--tier-blue);
}

.tier-badge.tier-green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--tier-green);
    border: 3px solid var(--tier-green);
}

.tier-badge.tier-yellow {
    background: rgba(245, 158, 11, 0.1);
    color: var(--tier-yellow);
    border: 3px solid var(--tier-yellow);
}

.tier-badge.tier-red {
    background: rgba(239, 68, 68, 0.1);
    color: var(--tier-red);
    border: 3px solid var(--tier-red);
}

.tier-description {
    font-size: 1.125rem;
    color: var(--text);
    margin-bottom: 1rem;
    font-weight: 500;
}

.data-info {
    font-size: 0.875rem;
    color: var(--text-light);
    line-height: 1.8;
}

/* ============================================================================
   Comparables Table
   ============================================================================ */

.comparables-table {
    overflow-x: auto;
}

.comparables-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.comparables-table th,
.comparables-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.comparables-table th {
    background: var(--navy);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
}

.comparables-table tbody tr {
    transition: var(--transition);
}

.comparables-table tbody tr:hover {
    background: var(--bg);
}

.comparables-table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================================================
   Loading & Messages
   ============================================================================ */

.loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 1rem;
    border: 4px solid var(--border);
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading p {
    color: var(--text-light);
    font-weight: 500;
}

.error {
    background: #fee2e2;
    color: #991b1b;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    border-left: 4px solid var(--tier-red);
    font-weight: 500;
    animation: shake 0.4s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.no-data {
    text-align: center;
    padding: 2rem;
    background: #fef3c7;
    border: 2px solid #fbbf24;
    border-radius: var(--radius);
}

.no-data h3 {
    color: #92400e;
    margin-bottom: 0.5rem;
}

.no-data p {
    color: #78350f;
}

/* ============================================================================
   Utilities
   ============================================================================ */

.hidden {
    display: none !important;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 768px) {
    body {
        padding-top: 60px;
    }
    
    .navbar {
        height: 60px;
    }
    
    .navbar-content {
        padding: 0 1rem;
    }
    
    .navbar-logo {
        font-size: 1.25rem;
    }
    
    .navbar-placeholder {
        display: none;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .tagline {
        font-size: 1rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-section {
        padding: 1rem;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .pricing-grid {
        grid-template-columns: 1fr;
    }
    
    .tier-badge {
        font-size: 1.25rem;
        padding: 0.75rem 1.5rem;
    }
    
    .comparables-table {
        font-size: 0.75rem;
    }
    
    .comparables-table th,
    .comparables-table td {
        padding: 0.75rem 0.5rem;
    }
    
    .price-range-marker-label {
        font-size: 0.65rem;
        padding: 0.4rem 0.6rem;
    }
    
    .history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .history-load-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem 0.75rem;
    }
    
    .navbar-icon {
        font-size: 1.5rem;
    }
    
    .navbar-logo {
        font-size: 1.125rem;
    }
    
    .price-range-labels {
        font-size: 0.75rem;
    }
}
