@tailwind base;
@tailwind components;
@tailwind utilities;

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #fafafa;
    color: #2d3748;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    height: 100vh;
    display: flex !important; /* Override any inline styles */
    flex-direction: row; /* Default for desktop */
}

.tab-navigation {
    display: none; /* Hidden by default on desktop */
}

.tab-content {
    display: block; /* Default for desktop */
    width: 100%; /* Take full width on desktop */
    height: 100%; /* Take full height on desktop */
    display: flex; /* Ensure content inside is flexed */
    flex-direction: column;
}

/* Desktop Layout Fix - Show both sections side by side */
@media (min-width: 769px) {
    .app-container {
        flex-direction: row;
    }
    
    .tab-navigation {
        display: none !important;
    }
    
    /* Force both tab contents to show on desktop */
    #chat-tab-content,
    #results-tab-content {
        display: flex !important;
        width: 50% !important;
        height: 100% !important;
    }
    
    #chat-tab-content {
        border-right: 1px solid #e2e8f0;
    }
    
    /* Override any hiding rules for desktop */
    .tab-content:not(.active) {
        display: flex !important; /* Override the mobile hiding rule */
    }
}

/* Chat Section */
.chat-section {
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
}

.chat-header-content {
    flex: 1;
}

.chat-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 4px;
}

.chat-header p {
    font-size: 14px;
    color: #64748b;
}

/* Improved Logout Button */
.logout-button {
    padding: 8px 16px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: fit-content;
}

.logout-button:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

.logout-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

.logout-button::before {
    content: "→";
    transform: rotate(180deg);
    font-weight: bold;
}

.chat-messages {
    flex: 1;
    padding: 16px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
}

.message.user {
    background: #3b82f6;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.ai {
    background: #f1f5f9;
    color: #374151;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-input-container {
    padding: 16px 24px 24px;
    border-top: 1px solid #f1f5f9;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    background: #f8fafc;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.chat-input:focus {
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.send-button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #3b82f6;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 16px;
}

.send-button:hover {
    background: #2563eb;
    transform: scale(1.05);
}

.send-button:active {
    transform: scale(0.95);
}

/* Results Section */
.results-section {
    width: 100%;
    height: 100%;
    background: #fafafa;
    display: flex;
    flex-direction: column;
}

/* Mobile Styles */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: 100%;
    }

    .tab-navigation {
        display: flex;
        width: 100%;
        border-bottom: 1px solid #e2e8f0;
        background: white;
    }

    .tab-button {
        flex: 1;
        padding: 16px 0;
        border: none;
        background: none;
        font-size: 16px;
        font-weight: 500;
        color: #64748b;
        cursor: pointer;
        transition: all 0.2s ease;
        border-bottom: 2px solid transparent;
    }

    .tab-button:hover {
        color: #3b82f6;
    }

    .tab-button.active {
        color: #3b82f6;
        border-bottom-color: #3b82f6;
    }

    .tab-content {
        flex: 1;
        overflow: hidden;
        width: 100% !important; /* Override desktop width on mobile */
    }

    .tab-content:not(.active) {
        display: none;
    }

    .chat-section,
    .results-section {
        width: 100%;
        height: 100%;
        border-right: none;
    }

    .chat-header {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .chat-header-content {
        width: 100%;
    }

    .logout-button {
        align-self: flex-end;
        margin-top: 8px;
    }

    .chat-messages {
        padding: 16px;
    }

    .chat-input-container {
        padding: 16px;
    }

    .results-container {
        padding: 16px;
    }
}

.results-header {
    padding: 24px 32px 16px;
    background: white;
    border-bottom: 1px solid #f1f5f9;
}

.results-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 4px;
}

.results-header p {
    font-size: 14px;
    color: #64748b;
}

.results-container {
    flex: 1;
    padding: 24px 32px;
    overflow-y: auto;
}

.property-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #f1f5f9;
    transition: all 0.2s ease;
}

.property-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.property-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.property-address {
    font-size: 16px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 4px;
}

.property-price {
    font-size: 24px;
    font-weight: 700;
    color: #059669;
}

.ai-analysis-details-title {
    margin-top: 24px;
    margin-bottom: 0px;
}

.sales-details-title {
    margin-top: 24px;
    margin-bottom: 0px;
}

.prop-details-title {
    margin-top: 24px;
    margin-bottom: 0px;
}

.property-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    margin-bottom: 2px;
}

.detail-value {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #64748b;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 24px;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    max-width: 300px;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Legacy compatibility - keeping old IDs for existing script.js */
#chat-display {
    flex: 1;
    padding: 16px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#results {
    flex: 1;
    padding: 24px 32px;
    overflow-y: auto;
}

#chat-input {
    /* Already styled above as .chat-input */
}

#chat-button {
    /* Already styled above as .send-button */
}

/* Handle existing chat message format with <div> elements */
#chat-display > div {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 0;
    word-wrap: break-word;
    background: #f1f5f9;
    color: #374151;
    border-bottom-left-radius: 4px;
}

/* Specific styling for user messages (containing "User:") */
#chat-display > div:nth-child(odd) {
    background: #3b82f6;
    color: white;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 16px;
}

/* Specific styling for system messages (containing "System:") */
#chat-display > div:nth-child(even) {
    background: #f1f5f9;
    color: #374151;
    align-self: flex-start;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 16px;
}

/* Style the strong tags within messages */
#chat-display div strong {
    font-weight: 600;
    margin-right: 8px;
}

/* Remove the mb-2 class margins since we're using flexbox gap */
#chat-display .mb-2 {
    margin-bottom: 0;
}

/* Property cards and content in results section */
#results > div,
#results .property-summary,
#results .comp-item {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #f1f5f9;
    transition: all 0.2s ease;
}

#results > div:hover,
#results .property-summary:hover,
#results .comp-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

/* Typography within results */
#results h1,
#results h2,
#results h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 12px;
    line-height: 1.3;
}

#results h1 {
    font-size: 20px;
}

#results p {
    font-size: 14px;
    line-height: 1.5;
    color: #374151;
    margin-bottom: 12px;
}

#results strong {
    font-weight: 600;
    color: #1a202c;
}

/* Address styling */
#results div:first-line {
    font-weight: 600;
    color: #1a202c;
}

/* Create property detail rows */
#results div {
    line-height: 1.6;
}

/* Don't apply card styling to empty state */
#results .empty-state {
    background: transparent;
    box-shadow: none;
    border: none;
    transform: none;
}

#results .empty-state:hover {
    box-shadow: none;
    transform: none;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

.loading-text {
    font-size: 16px;
    color: #374151;
}

.wrapper {
  position: relative;
  overflow: hidden; /* to contain floated elements */
}

.location-title {
    float: left;
}

.ai-score {
  float: right;
  font-size: small;
  padding: 0.25em 0.75em;
  border-radius: 9999px; /* makes it pill-shaped */
  display: inline-block;
  font-weight: 500; /* optional, for better visual weight */
}

.ai-score-green {
    background-color: #dcfce7; /* Tailwind green-200 */
    color: #166534 !important; /* Tailwind green-800 */
}

.ai-score-yellow {
    background-color: #fef9c3; /* Tailwind yellow-200 */
    color: #854d0e; /* Tailwind yellow-800 */
}

.ai-score-red {
    background-color: #fee2e2; /* Tailwind red-200 */
    color: #991b1b; /* Tailwind red-800 */
}

.sales-price-green {
    color: #059669 !important; /* Tailwind green-600 */
}

.sale-details-row {
    display: flex;
    gap: 16px;
}

.property-details-row {
    display: flex;
    gap: 16px;
    font-size: small;
}

.ai-market-summary {
    background-color: rgb(175, 224, 255) !important;
}

.suggested-adjustments {
    margin: 4px 0;
}

.suggested-adjustments-title {
    font-size: small;
}

.suggested-adjustments-amount {
    font-size: small !important;
    color: darkblue;
}

.user {
    background-color: #e0e0e0; /* Grey */
    color: #000;
    padding: 8px 12px;
    border-radius: 8px;
    align-self: flex-end;
}

.ai {
    background-color: #add8e6; /* Blue */
    color: #000;
    padding: 8px 12px;
    border-radius: 8px;
    align-self: flex-start;
}

/* Enhanced Login Container Styles */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    padding: 20px;
    box-sizing: border-box;
    z-index: 1000;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    margin: 0 auto;
}

.login-container h2 {
    font-size: 2rem;
    color: #333;
    margin-bottom: 8px;
    text-align: center;
    font-weight: 600;
}

.login-subtitle {
    color: #666;
    text-align: center;
    margin-bottom: 32px;
    font-size: 0.95rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    position: relative;
}

.login-container input {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    font-size: 1rem;
    background: #f8fafc;
    transition: all 0.3s ease;
    outline: none;
}

.login-container input:focus {
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    transform: translateY(-1px);
}

.login-container input::placeholder {
    color: #9ca3af;
}

.login-button-primary {
    width: 100%;
    padding: 16px 20px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    margin-top: 8px;
}

.login-button-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}

.login-button-primary:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.login-error {
    margin-top: 16px;
    padding: 12px 16px;
    background: #fee2e2;
    color: #dc2626;
    border-radius: 8px;
    font-size: 0.9rem;
    border-left: 4px solid #dc2626;
    display: none;
}

.login-error.show {
    display: block;
}

.login-footer {
    margin-top: 24px;
    text-align: center;
    color: #6b7280;
    font-size: 0.9rem;
}

/* Loading state for login button */
.login-button-primary.loading {
    position: relative;
    color: transparent;
}

.login-button-primary.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Responsive adjustments for login */
@media (max-width: 480px) {
    .login-card {
        padding: 32px 24px;
        margin: 20px;
    }
    
    .login-container h2 {
        font-size: 1.75rem;
    }
}