/**
 * Repa Donor Microsite Styles
 * Custom styling matching the Lovable prototype and brand guidelines
 */

/* Color Palette */
:root {
    --repa-green-primary: #2D9B6E;
    --repa-green-light: #E8F5F0;
    --repa-green-dark: #1F6B4D;
    --repa-orange: #FF8C42;
    --repa-blue: #4A90E2;
    --repa-gray-light: #F5F7FA;
    --repa-gray-medium: #E5E7EB;
    --repa-gray-dark: #4B5563;
    --repa-text-primary: #1F2937;
    --repa-text-secondary: #6B7280;
}

/* Reset and base */
* {
    box-sizing: border-box;
}

body.repa-page {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--repa-gray-light);
    color: var(--repa-text-primary);
}

/* Header */
.repa-header {
    background: linear-gradient(135deg, #2D9B6E 0%, #1F6B4D 100%);
    color: white;
    padding: 2rem 1rem;
    position: relative;
}

.repa-header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.repa-header h1 {
    font-size: 2rem;
    margin: 0 0 0.5rem 0;
    font-weight: 600;
}

.repa-header .subtitle {
    font-size: 1rem;
    opacity: 0.9;
    margin: 0;
}

.repa-header-link {
    color: white;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 600;
}

.repa-header-link:hover {
    text-decoration: underline;
}

.repa-export-btn {
    background-color: #1F6B4D;
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: all 0.2s;
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.repa-export-btn:hover {
    background-color: #164D37;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.25);
}

/* Main container */
.repa-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Summary Cards Grid */
.repa-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.repa-card {
    background: var(--repa-green-light);
    border-radius: 12px;
    padding: 1.5rem;
    padding-bottom: 4rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.2s;
    position: relative;
}

.repa-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.repa-card-content h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--repa-text-secondary);
    margin: 0 0 0.5rem 0;
}

.repa-card-content .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--repa-text-primary);
    margin: 0;
}

.repa-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.icon-green {
    background-color: #C6E7D9;
    color: var(--repa-green-primary);
}

.icon-teal {
    background-color: #D1FAE5;
    color: #059669;
}

.icon-orange {
    background-color: #FED7AA;
    color: #EA580C;
}

/* Impact Stats Row */
.repa-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.repa-stat-box {
    background: transparent;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

/* Override alignment for specific positions */
.repa-stat-box:nth-child(1) {
    text-align: left;
}

.repa-stat-box:nth-child(2) {
    text-align: center;
}

.repa-stat-box:nth-child(3) {
    text-align: right;
}

.repa-stat-box h4 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--repa-text-secondary);
    margin: 0 0 0.5rem 0;
}

.repa-stat-box .stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.stat-value.green {
    color: var(--repa-green-primary);
}

.stat-value.orange {
    color: var(--repa-orange);
}

/* Crowdfund Message */
.repa-message {
    background: transparent;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    text-align: center;
}

.repa-message p {
    margin: 0;
    font-size: 1.125rem;
    color: var(--repa-text-primary);
}

.repa-message .highlight {
    color: var(--repa-green-primary);
    font-weight: 600;
}

/* Transaction Table Section */
.repa-transactions {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-left: -1rem;
    margin-right: -1rem;
}

.repa-transactions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.repa-transactions h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: var(--repa-text-primary);
}

.repa-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.repa-table thead {
    background-color: var(--repa-gray-light);
}

.repa-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--repa-text-secondary);
    font-size: 0.75rem;
    border-bottom: 2px solid var(--repa-gray-medium);
    position: relative;
}

.repa-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--repa-gray-medium);
    color: var(--repa-text-primary);
    white-space: nowrap;
}

.repa-table tbody tr:hover {
    background-color: var(--repa-gray-light);
}

/* Plastic type badges with resin identification codes */
.plastic-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    border-radius: 14px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    white-space: nowrap;
    background-color: var(--repa-green-light);
    color: var(--repa-green-dark);
    border: 1px solid #6EE7B7;
}

.plastic-badge .resin-symbol {
    font-size: 0.9rem;
    line-height: 1;
}

.plastic-badge .resin-code {
    font-weight: 800;
    font-size: 0.8rem;
}

/* Login Page Styles */
.repa-login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.repa-login-box {
    background: white;
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    width: 100%;
}

.repa-login-box h1 {
    font-size: 1.75rem;
    margin: 0 0 0.5rem 0;
    color: var(--repa-green-primary);
}

.repa-login-box .subtitle {
    font-size: 0.875rem;
    color: var(--repa-text-secondary);
    margin: 0 0 2rem 0;
}

.repa-form-group {
    margin-bottom: 1.5rem;
}

.repa-form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--repa-text-primary);
    margin-bottom: 0.5rem;
}

.repa-form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--repa-gray-medium);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.repa-form-group input:focus {
    outline: none;
    border-color: var(--repa-green-primary);
    box-shadow: 0 0 0 3px rgba(45, 155, 110, 0.1);
}

.repa-btn-primary {
    width: 100%;
    padding: 0.875rem;
    background-color: var(--repa-green-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

.repa-btn-primary:disabled {
    background-color: var(--repa-gray-medium);
    cursor: not-allowed;
}

.repa-error {
    background-color: #FEE2E2;
    border: 1px solid #FCA5A5;
    color: #991B1B;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 960px) {
    .repa-summary-grid,
    .repa-stats-row {
        grid-template-columns: 1fr;
    }

    /* Center align all stat boxes when stacked */
    .repa-stat-box:nth-child(1),
    .repa-stat-box:nth-child(2),
    .repa-stat-box:nth-child(3) {
        text-align: center;
    }
}

@media (max-width: 768px) {
    .repa-header h1 {
        font-size: 1.5rem;
    }

    .repa-header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    /* Center align all stat boxes on mobile */
    .repa-stat-box:nth-child(1),
    .repa-stat-box:nth-child(2),
    .repa-stat-box:nth-child(3) {
        text-align: center;
    }

    .repa-table {
        font-size: 0.75rem;
    }

    .repa-table th,
    .repa-table td {
        padding: 0.5rem;
    }

    .repa-tooltip {
        min-width: 180px;
        max-width: 250px;
        font-size: 0.75rem;
    }
}

/* ============================================
   Clickable Total Donated card
   ============================================ */

a.repa-card-clickable {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    position: relative;
    flex-wrap: wrap;
    border: 1.5px solid transparent;
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}

a.repa-card-clickable:hover {
    box-shadow: 0 6px 16px rgba(45, 155, 110, 0.25);
    transform: translateY(-1px);
    border-color: var(--repa-green-primary);
}

/* CTA label strip at bottom of card */
.repa-card-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.6rem 1.5rem;
    border-top: 1px solid rgba(45, 155, 110, 0.15);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--repa-green-primary);
    letter-spacing: 0.01em;
    transition: gap 0.2s;
    text-align: center;
}

.repa-card-cta-arrow {
    font-size: 1.15rem;
    line-height: 1;
    position: relative;
    top: -0.05em;
    transition: transform 0.2s;
}

a.repa-card-clickable:hover .repa-card-cta {
    gap: 0.5rem;
}

a.repa-card-clickable:hover .repa-card-cta-arrow {
    transform: translateX(2px);
}

/* ============================================
   Donation Breakdown page
   ============================================ */

.repa-breakdown-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
}

.repa-breakdown-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.repa-breakdown-subtitle {
    color: var(--repa-text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
    margin: 0.5rem 0 0 0;
}

.repa-breakdown-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--repa-text-primary);
}

.repa-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--repa-text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
    transition: color 0.2s;
    white-space: nowrap;
}

.repa-back-link:hover {
    color: var(--repa-text-primary);
}

.repa-back-link svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.repa-info-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--repa-green-dark);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border: 1.5px solid var(--repa-green-primary);
    border-radius: 100px;
    transition: all 0.2s;
    white-space: nowrap;
}

.repa-info-link:hover {
    background-color: var(--repa-green-primary);
    color: white;
}

.repa-breakdown-table {
    font-size: 0.85rem;
}

.repa-breakdown-table .repa-col-right {
    text-align: right;
}

.repa-empty-message {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--repa-text-secondary);
    font-style: italic;
}

/* ============================================
   Column info tooltips
   ============================================ */

.repa-th-with-info {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.repa-info-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: var(--repa-text-secondary);
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.repa-info-btn:hover {
    opacity: 1;
}

.repa-info-btn svg {
    width: 14px;
    height: 14px;
}

.repa-tooltip {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: white;
    border: 1px solid var(--repa-gray-medium);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    max-width: 300px;
    white-space: normal;
    font-weight: 400;
    font-size: 0.8125rem;
    color: var(--repa-text-primary);
    line-height: 1.5;
}

.repa-tooltip.open {
    display: block;
}

.repa-tooltip-close {
    position: absolute;
    top: 0.25rem;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--repa-text-secondary);
    padding: 0;
    line-height: 1;
}

.repa-tooltip-close:hover {
    color: var(--repa-text-primary);
}

.repa-tooltip p {
    margin: 0;
}

.repa-tooltip a {
    color: var(--repa-green-primary);
    text-decoration: underline;
}

/* ============================================
   Info Sidebar
   ============================================ */

.repa-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
}

.repa-sidebar-overlay.open {
    display: block;
}

.repa-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    max-width: 90vw;
    height: 100vh;
    height: 100dvh;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: right 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.repa-sidebar.open {
    right: 0;
}

.repa-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--repa-gray-medium);
    position: sticky;
    top: 0;
    background: white;
}

.repa-sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--repa-text-primary);
}

.repa-sidebar-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--repa-text-secondary);
    padding: 0;
    line-height: 1;
}

.repa-sidebar-close:hover {
    color: var(--repa-text-primary);
}

.repa-sidebar-body {
    padding: 1.5rem;
}

.repa-sidebar-body h4 {
    color: var(--repa-green-dark);
    margin: 1.25rem 0 0.5rem 0;
    font-size: 0.95rem;
}

.repa-sidebar-body p {
    color: var(--repa-text-secondary);
    line-height: 1.6;
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
}
