/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--bg-light);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

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

.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
    font-size: 1.1rem;
}

.help-text {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

/* Header */
.header {
    background-color: var(--bg-white);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary-color);
}

.nav-link.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

.user-info {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Main Content */
.main-content {
    min-height: calc(100vh - 160px);
    padding: 2rem 0;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* Page Header (Phase 3) */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h2,
.page-header h3 {
    font-size: 2rem;
    color: var(--text-dark);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 12px;
    margin-bottom: 3rem;
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.95;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Features Section */
.features {
    padding: 2rem 0;
}

.features h3 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--text-dark);
}

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

.feature-card {
    background: var(--bg-white);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    text-align: center;
    transition: transform 0.2s;
}

.feature-card:hover {
    transform: translateY(-4px);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature-card h4 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.feature-card p {
    color: var(--text-light);
}

/* Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.category-card {
    background: var(--bg-white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary-color);
    transition: all 0.2s;
}

.category-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.category-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.category-card p {
    color: var(--text-light);
    font-size: 0.95rem;
}

/* Requests & Services Lists (Phase 3) */
.requests-list,
.services-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.request-card,
.service-card {
    background: var(--bg-white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary-color);
    transition: all 0.2s;
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.3rem;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.card-category {
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 600;
}

.card-status {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-open { background: #dbeafe; color: #1e40af; }
.status-matching { background: #fef3c7; color: #92400e; }
.status-negotiating { background: #fce7f3; color: #9f1239; }
.status-in_progress { background: #dcfce7; color: #166534; }
.status-completed { background: #d1fae5; color: #065f46; }
.status-cancelled { background: #fee2e2; color: #991b1b; }

/* Match Status Colors (Phase 4) */
.status-pending { background: #fef3c7; color: #92400e; }
.status-accepted { background: #d1fae5; color: #065f46; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.status-expired { background: #f3f4f6; color: #6b7280; }
.status-withdrawn { background: #f3f4f6; color: #6b7280; }

.card-body {
    margin-bottom: 1rem;
}

.card-description {
    color: var(--text-light);
    margin-bottom: 1rem;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.meta-item.timer {
    color: var(--warning-color);
    font-weight: 600;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #16a34a;
}

.btn-danger {
    background-color: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

/* Form Container (Phase 3) */
.form-container {
    background: var(--bg-white);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
}

.form-container h3 {
    margin-bottom: 1.5rem;
    color: var(--text-dark);
}

/* Matches (Phase 4) */
.tab-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-button {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-button:hover {
    color: var(--primary-color);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.match-view {
    display: block;
}

.match-view.hidden {
    display: none;
}

.matches-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.match-card {
    background: var(--bg-white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--secondary-color);
    transition: all 0.2s;
}

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

.match-card.match-pending {
    border-left-color: var(--warning-color);
    background: linear-gradient(to right, #fffbeb 0%, var(--bg-white) 10%);
}

.match-card.match-small {
    padding: 1rem;
}

.match-card.match-small .card-title {
    font-size: 1.1rem;
}

.match-group {
    margin-bottom: 2rem;
}

.match-group h3 {
    color: var(--text-dark);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

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

/* Negotiations Page (Phase 5) */
.negotiations-list {
    display: grid;
    gap: 1rem;
}

.negotiation-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.2s;
}

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

.negotiation-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.negotiation-status {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
}

.negotiation-status.negotiating { background: #fef3c7; color: #92400e; }
.negotiation-status.accepted { background: #d1fae5; color: #065f46; }
.negotiation-status.completed { background: #dbeafe; color: #1e40af; }
.negotiation-status.cancelled { background: #fee2e2; color: #991b1b; }
.negotiation-status.rejected { background: #f3f4f6; color: #6b7280; }

.negotiation-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.unread-badge {
    background: var(--error-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* Chat Modal (Phase 5) */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.chat-modal-content {
    background: var(--bg-white);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.btn-close:hover {
    color: var(--error-color);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.negotiation-info {
    margin-bottom: 1rem;
}

.chat-messages {
    min-height: 300px;
    max-height: 400px;
    overflow-y: auto;
    margin: 1rem 0;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: 8px;
}

.chat-message {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

.chat-message.mine {
    align-items: flex-end;
}

.chat-message.system {
    align-items: center;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    max-width: 70%;
    word-wrap: break-word;
}

.chat-message.mine .message-bubble {
    background: var(--primary-color);
    color: white;
}

.chat-message.other .message-bubble {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    color: var(--text-dark);
}

.chat-message.system .message-bubble {
    background: var(--bg-light);
    color: var(--text-light);
    font-style: italic;
    text-align: center;
    max-width: 100%;
}

.message-sender {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.chat-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.chat-form input {
    flex: 1;
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-size: 1rem;
}

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

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

.btn-secondary {
    background-color: transparent;
    color: white;
    border: 2px solid white;
}

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

.btn-block {
    width: 100%;
}

.button-group {
    display: flex;
    gap: 1rem;
}

/* Forms */
.auth-container {
    max-width: 500px;
    margin: 0 auto;
    background: var(--bg-white);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}

.auth-container h2,
.auth-container h3 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-dark);
}

.auth-container h3 {
    font-size: 1.1rem;
    margin-top: 1.5rem;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.form-group label {
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.auth-footer {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-light);
}

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

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

/* Profile */
.profile-container {
    max-width: 700px;
    margin: 0 auto;
    background: var(--bg-white);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2.5rem;
    font-weight: 700;
}

.profile-info h3 {
    font-size: 1.8rem;
    margin-bottom: 0.25rem;
}

.profile-info p {
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    background-color: var(--primary-color);
    color: white;
}

.profile-details {
    margin-bottom: 2rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-label {
    font-weight: 600;
    color: var(--text-light);
}

.detail-value {
    color: var(--text-dark);
}

/* Error Messages */
.error-message {
    padding: 0.75rem;
    background-color: #fee2e2;
    color: var(--error-color);
    border-radius: 6px;
    font-size: 0.9rem;
    display: none;
}

.error-message:not(:empty) {
    display: block;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--text-dark);
    color: white;
    padding: 1rem 2rem;
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    transition: bottom 0.3s;
    z-index: 1000;
    min-width: 300px;
    text-align: center;
}

.toast.show {
    bottom: 30px;
}

.toast.success {
    background-color: var(--success-color);
}

.toast.warning {
    background-color: var(--warning-color);
}

.toast.error {
    background-color: var(--error-color);
}

/* Footer */
.footer {
    background-color: var(--text-dark);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

.footer p {
    margin: 0.25rem 0;
    opacity: 0.8;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .hero h2 {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .feature-grid {
        grid-template-columns: 1fr;
    }

    .categories-grid {
        grid-template-columns: 1fr;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
    }

    .detail-row {
        flex-direction: column;
        gap: 0.25rem;
    }

    .button-group {
        flex-direction: column;
    }
    
    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .card-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .card-actions {
        width: 100%;
    }
    
    .card-actions .btn {
        flex: 1;
    }
    
    .tab-container {
        overflow-x: auto;
    }
    
    .tab-button {
        white-space: nowrap;
    }
    
    .chat-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .negotiation-info-grid {
        grid-template-columns: 1fr;
    }
}
