/* Modern Referrer Management Styles */

.referrer-container {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin: 20px;
    animation: fadeInUp 0.5s ease;
}

.referrer-header {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-dark) 100%);
    color: white;
    padding: 32px;
    position: relative;
    overflow: hidden;
}

.referrer-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.3;
}

.referrer-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    color: white !important;
}

.referrer-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin: 8px 0 0 0;
    position: relative;
    z-index: 1;
}

/* Add Referrer Section */
.add-referrer-section {
    background: white;
    padding: 24px 32px;
    border-bottom: 1px solid #e2e8f0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-green);
    margin: 0;
}

.toggle-form-btn {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-dark) 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(45, 90, 61, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
}

.toggle-form-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(45, 90, 61, 0.4);
}

.btn-icon {
    font-size: 1.1rem;
}

/* Modern Referrer Form */
.modern-referrer-form {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 16px;
    padding: 24px;
    margin-top: 20px;
    border: 2px solid #e2e8f0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: var(--primary-green);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
    color: #1e293b;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.1);
    transform: translateY(-2px);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.save-btn {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-dark) 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(45, 90, 61, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(45, 90, 61, 0.4);
}

.cancel-btn {
    background: linear-gradient(135deg, #64748b, #475569);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.3);
}

.cancel-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(100, 116, 139, 0.4);
}

/* Table Section */
.table-section {
    padding: 24px 32px;
}

.referrer-stats {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stats-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stats-number {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-green);
    line-height: 1;
}

.stats-label {
    font-size: 0.8rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.table-container {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
}

/* Modern Referrer Table */
.modern-referrer-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.modern-referrer-table thead {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-dark) 100%) !important;
    color: white !important;
}

.modern-referrer-table th {
    padding: 20px 24px;
    text-align: left;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    position: relative;
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-dark) 100%) !important;
    color: white !important;
}

.modern-referrer-table th::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-green-light), var(--primary-blue));
}

.modern-referrer-table tbody tr {
    transition: all 0.3s ease;
    border-bottom: 1px solid #f1f5f9;
}

.modern-referrer-table tbody tr:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.modern-referrer-table td {
    padding: 20px 24px;
    border: none;
    vertical-align: middle;
    color: #334155;
    font-size: 0.95rem;
}

/* Referrer Info Styling */
.referrer-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.referrer-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
}

.referrer-details h4 {
    margin: 0;
    font-weight: 600;
    color: #1e293b;
    font-size: 1rem;
}

.referrer-details p {
    margin: 2px 0 0 0;
    color: #64748b;
    font-size: 0.85rem;
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.contact-email {
    font-weight: 600;
    color: #1e293b;
}

.contact-meta {
    font-size: 0.85rem;
    color: #64748b;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 8px;
}

.delete-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.delete-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 32px;
    color: #64748b;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #334155;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Legacy compatibility styles */
#refsTable { 
    border-collapse: collapse; 
    width: 100%; 
    margin-top: 1em; 
}

#refsTable th, 
#refsTable td { 
    border: 1px solid #888; 
    padding: 8px; 
}

#refsTable th { 
    background: linear-gradient(135deg, #2d5a3d 0%, #1e3a2a 100%) !important;
    background-color: #2d5a3d !important;
    color: white !important;
    font-weight: 700 !important;
}

/* Additional fallback for table headers */
table thead,
table th,
.modern-referrer-table thead,
.modern-referrer-table th {
    background: linear-gradient(135deg, #2d5a3d 0%, #1e3a2a 100%) !important;
    background-color: #2d5a3d !important;
    color: white !important;
}

.delBtn {
    background: #f44336;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.delBtn:hover {
    background: #d32f2f;
    transform: translateY(-1px);
}

/* Mobile Cards (hidden by default, shown on very small screens) */
.mobile-referrer-cards {
    display: none;
}

.referrer-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.referrer-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.referrer-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.referrer-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
}

.referrer-card-info h4 {
    margin: 0;
    font-size: 1.1rem;
    color: #1e293b;
    font-weight: 600;
}

.referrer-card-info p {
    margin: 4px 0 0 0;
    font-size: 0.8rem;
    color: #64748b;
}

.referrer-card-contact {
    margin-bottom: 12px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
}

.referrer-card-contact .contact-email {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
    word-break: break-word;
}

.referrer-card-actions {
    display: flex;
    justify-content: flex-end;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsiveness - Enhanced */
@media (max-width: 768px) {
    .referrer-container {
        margin: 10px;
        border-radius: 12px;
    }

    .referrer-header {
        padding: 20px 16px;
    }

    .referrer-title {
        font-size: 1.8rem;
    }

    .add-referrer-section,
    .table-section {
        padding: 16px;
    }

    .section-header {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Make table container horizontally scrollable */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
    }

    /* Adjust table for mobile */
    .modern-referrer-table {
        min-width: 600px; /* Minimum width to prevent cramping */
        width: 100%;
    }

    .modern-referrer-table th,
    .modern-referrer-table td {
        padding: 12px 8px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    /* Compact referrer info for mobile */
    .referrer-info {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        min-width: 140px;
    }

    .referrer-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
        flex-shrink: 0;
    }

    .referrer-details h4 {
        font-size: 0.9rem;
        margin: 0;
        line-height: 1.2;
    }

    .referrer-details p {
        font-size: 0.75rem;
        margin: 2px 0 0 0;
    }

    /* Compact contact info */
    .contact-info {
        gap: 2px;
        min-width: 180px;
    }

    .contact-email {
        font-size: 0.85rem;
        word-break: break-word;
    }

    .contact-meta {
        font-size: 0.75rem;
    }

    /* Compact action buttons */
    .action-buttons {
        flex-direction: row;
        gap: 4px;
        justify-content: center;
        min-width: 80px;
    }

    .delete-btn {
        font-size: 0.75rem;
        padding: 6px 10px;
        white-space: nowrap;
    }

    .delete-btn span {
        font-size: 0.8rem;
    }
}

/* Even smaller screens (iPhone SE, etc.) */
@media (max-width: 480px) {
    .referrer-container {
        margin: 5px;
    }

    .referrer-header {
        padding: 16px 12px;
    }

    .referrer-title {
        font-size: 1.5rem;
    }

    .add-referrer-section,
    .table-section {
        padding: 12px;
    }

    /* Hide table on very small screens */
    .table-container {
        display: none;
    }

    /* Show card layout instead */
    .mobile-referrer-cards {
        display: block !important;
    }

    .referrer-card .delete-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}

/* Ensure table is visible on larger screens */
@media (min-width: 481px) {
    .table-container {
        display: block !important;
    }
    .mobile-referrer-cards {
        display: none !important;
    }
}