/*
PCF Climate Chatbot - Complaint System Styles
Complaint submission and management interface
*/

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--overlay-color, rgba(15, 23, 42, 0.55));
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

/* Responsive widths: prevent horizontal overflow */
.complaint-modal { width: min(600px, 95vw); }
.complaint-dashboard { width: min(1000px, 96vw); }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Modal Header */
.modal-header {
    background: var(--header-gradient, linear-gradient(135deg, var(--primary-color, #38a169), var(--secondary-color, #2f855a)));
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Close button inherits unified styles from style.css */
.modal-close { color: #ffffffd9; }

/* Modal Body */
.modal-body {
    padding: 20px;
    max-height: calc(90vh - 80px);
    overflow-y: auto;
    background: var(--bg-primary);
}

@media (max-width: 600px) {
    .modal-header { padding: 12px 14px; }
    .modal-body { padding: 14px; }
    .form-actions { flex-wrap: wrap; justify-content: center; gap: 10px; }
}

/* Complaint Form */
.complaint-form { display: flex; flex-direction: column; gap: 20px; }

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

.form-group label {
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.form-group label i { color: var(--primary-color); }

.required { color: #e74c3c; }

.optional {
    color: #7f8c8d;
    font-weight: normal;
    font-size: 0.85rem;
}

/* Form Inputs */
.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-ring, rgba(56, 161, 105, 0.15));
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* Character Counter */
.char-counter {
    align-self: flex-end;
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-top: -5px;
}

.char-counter.warning {
    color: #f39c12;
}

.char-counter.danger {
    color: #e74c3c;
}

/* File Upload */
.file-upload-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.file-drop-zone {
    border: 2px dashed #cbd5e0;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f8f9fa;
}

.file-drop-zone:hover {
    border-color: var(--primary-color);
    background: #f0f9f5;
}

.file-drop-zone i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    display: block;
}

.file-drop-zone p {
    margin: 0 0 5px 0;
    font-weight: 500;
    color: #353740;
}

.file-drop-zone small {
    color: #7f8c8d;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e1e5e9;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-info i {
    color: var(--primary-color);
}

.file-name {
    font-weight: 500;
}

.file-size {
    color: #7f8c8d;
    font-size: 0.85rem;
}

.file-remove {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.file-remove:hover {
    background: rgba(231, 76, 60, 0.1);
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 1px solid #e1e5e9;
    margin-top: 10px;
    /* Keep actions visible when scrolling long forms (especially on mobile) */
    position: sticky;
    bottom: 0;
    background: var(--bg-primary);
    padding-bottom: 12px;
    z-index: 2;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--primary-shadow, rgba(56, 161, 105, 0.3));
}

.btn-secondary {
    background: #f1f3f4;
    color: #353740;
}

.btn-secondary:hover {
    background: #e8eaed;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Form Messages */
.form-message {
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.form-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.form-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.form-message.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* Dashboard Styles */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.2s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: white;
    background: var(--primary-color);
}

.stat-icon.open {
    background: #f39c12;
}

.stat-icon.resolved {
    background: #27ae60;
}

.stat-icon.recent {
    background: #3498db;
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #2c3e50;
}

.stat-label {
    font-size: 0.9rem;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Dashboard Filters */
.dashboard-filters {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e1e5e9;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #353740;
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    min-width: 120px;
}

/* Complaints List */
.complaints-list {
    min-height: 400px;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px;
    color: #7f8c8d;
}

.loading-spinner i {
    font-size: 2rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.complaint-item {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

.complaint-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.complaint-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.complaint-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.complaint-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.complaint-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-open {
    background: #fff3cd;
    color: #856404;
}

.status-in_progress {
    background: #cce7ff;
    color: #004085;
}

.status-resolved {
    background: #d4edda;
    color: #155724;
}

.status-closed {
    background: #f1f3f4;
    color: #353740;
}

.priority-high {
    background: #f8d7da;
    color: #721c24;
}

.priority-medium {
    background: #fff3cd;
    color: #856404;
}

.priority-low {
    background: #d4edda;
    color: #155724;
}

.type-bug {
    background: #f8d7da;
    color: #721c24;
}

.type-feature {
    background: #cce7ff;
    color: #004085;
}

.type-general {
    background: #f1f3f4;
    color: #353740;
}

.complaint-description {
    color: #7f8c8d;
    line-height: 1.5;
    margin-bottom: 15px;
}

.complaint-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 15px;
    border-top: 1px solid #e1e5e9;
}

.complaint-date {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.complaint-actions {
    display: flex;
    gap: 10px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Complaint Button in Sidebar */
.complaint-btn {
    width: 100%;
    padding: 12px 16px;
    margin: 10px 0;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.complaint-btn:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.complaint-btn i {
    font-size: 1.1rem;
}

/* Complaint Details Modal Enhancements */
.complaint-modal.complaint-details {
    width: 760px;
}

.complaint-details .modal-header h3 i {
    opacity: 0.95;
}

.complaint-details-body {
    display: block;
}

.complaint-details-body .details-row {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 18px;
}

.complaint-details-body .details-col {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.complaint-details-body .details-field {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
}

.complaint-details-body .details-field .label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #64748b; /* slate-500 */
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.complaint-details-body .details-field .value {
    font-size: 14px;
    color: #1f2937; /* gray-800 */
    line-height: 1.5;
    white-space: pre-wrap;
}

.complaint-details-body .details-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.complaint-details-body .details-meta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
}

.complaint-details-body .details-meta > div {
    font-size: 13px;
    color: #374151; /* gray-700 */
}

.complaint-details-body .details-meta i {
    color: var(--primary-color);
    margin-right: 6px;
}

/* Admin reply styling */
.complaint-details-body .admin-reply {
    background: #ecfdf5; /* emerald-50 */
    border: 1px solid #a7f3d0; /* emerald-200 */
    color: #065f46; /* emerald-800 */
    padding: 12px 14px;
    border-radius: 10px;
}

.complaint-details-body .admin-reply i {
    color: var(--primary-color);
    margin-right: 6px;
}

/* Responsive adjustments */
@media (max-width: 820px) {
    .complaint-modal.complaint-details {
        width: 95vw;
    }
    .complaint-details-body .details-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .complaint-modal,
    .complaint-dashboard {
        width: 95vw;
        margin: 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .dashboard-filters .filter-group {
        flex: 1;
    }
    
    .complaint-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .complaint-meta {
        justify-content: flex-start;
    }
    
    .complaint-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .form-actions {
        flex-direction: column;
        /* Lift actions slightly above bottom edge on mobile to avoid being half hidden */
        bottom: 12px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 480px) {
    .dashboard-stats {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
}

/* RTL Support */
[dir="rtl"] .modal-content {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .form-group label {
    flex-direction: row-reverse;
}

[dir="rtl"] .complaint-header {
    flex-direction: row-reverse;
}

[dir="rtl"] .complaint-meta {
    flex-direction: row-reverse;
}

[dir="rtl"] .form-actions {
    flex-direction: row-reverse;
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-up {
    animation: slideUp 0.3s ease;
}

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

/* Notification Integration */
.complaint-notification {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.complaint-notification .notification-icon {
    color: white;
}