/**
 * Greendome Engineering Support System
 * Full CSS - Mobile-First, Responsive
 */

/* =========================
   :root - Theme Variables
========================= */
:root {
    --primary-color: #2c5f2d;
    --secondary-color: #97bc62;
    --accent-color: #ff6b35;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --background: #f8f9fa;
    --white: #ffffff;
    --border: #dee2e6;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
}

/* =========================
   Global Styles
========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--background);
    color: var(--text-dark);
    line-height: 1.6;
    font-size: 16px;
}

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

/* =========================
   Header / Top Bar
========================= */
.header,
.top-bar {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    padding: 20px 30px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header h1,
.top-bar-title {
    font-size: 24px;
    font-weight: 700;
}

.header p,
.top-bar-user {
    font-size: 13px;
    opacity: 0.9;
}

.header .tagline {
    font-size: 11px;
    opacity: 0.85;
    font-style: italic;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.top-bar-right {
    display: flex;
    gap: 10px;
}

.top-bar-btn {
    color: var(--white);
    text-decoration: none;
    padding: 10px 20px;
    background: rgba(255,255,255,0.2);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    border: none;
    cursor: pointer;
}

.top-bar-btn:hover { background: rgba(255,255,255,0.3); }
.btn-logout { background: rgba(220, 53, 69, 0.9); }
.btn-logout:hover { background: var(--danger); }
.btn-trash { background: rgba(255, 193, 7, 0.9); }
.btn-trash:hover { background: var(--warning); }

/* =========================
   Navigation Tabs
========================= */
.nav-tabs {
    background: var(--white);
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e9ecef;
    overflow-x: auto;
}

.nav-tab {
    padding: 15px 25px;
    text-decoration: none;
    color: #6c757d;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    font-weight: 600;
}

.nav-tab:hover { background: var(--background); color: var(--primary-color); }
.nav-tab.active { color: var(--primary-color); border-bottom-color: var(--primary-color); background: var(--background); }

/* =========================
   Cards & Stats
========================= */
.card, .stat-card, .chart-container, .form-section {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 25px;
    margin-bottom: 25px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card {
    text-align: center;
    border-left: 4px solid var(--primary-color);
}

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

.stat-number { font-size: 36px; font-weight: 700; color: var(--primary-color); margin-bottom: 8px; }
.stat-label { font-size: 13px; color: #6c757d; text-transform: uppercase; font-weight: 600; }

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

/* =========================
   Buttons
========================= */
.btn {
    padding: 12px 28px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary { background: var(--primary-color); color: var(--white); }
.btn-primary:hover { background: #1e4320; }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #218838; }
.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover { background: #e0a800; }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #c82333; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-xs { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* =========================
   Forms
========================= */
.form-group, .form-section { margin-bottom: 20px; }

label, .form-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
}

label.required::after { content: " *"; color: var(--danger); }

input[type="text"], input[type="email"], input[type="tel"],
select, textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s, box-shadow 0.3s;
}

textarea { min-height: 120px; resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(44,95,45,0.1);
}

/* =========================
   Alerts
========================= */
.alert {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

.alert-success { background: #d4edda; color: #155724; border-left: 4px solid var(--success); }
.alert-error { background: #f8d7da; color: #721c24; border-left: 4px solid var(--danger); }
.alert-info { background: #d1ecf1; color: #0c5460; border-left: 4px solid var(--info); }
.alert-warning { background: #fff3cd; color: #856404; border-left: 4px solid var(--warning); }

/* =========================
   Tables
========================= */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--white); }
thead { background: var(--background); }
th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-dark);
}
tbody tr:hover { background: #f8f9fa; }

/* =========================
   Badges
========================= */
.badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-new { background: var(--info); color: var(--white); }
.badge-enquiry { background: var(--warning); color: #000; }
.badge-followup { background: var(--secondary-color); color: var(--white); }
.badge-responded { background: var(--success); color: var(--white); }
.badge-closed { background: var(--text-light); color: var(--white); }

/* =========================
   Conversation / Chat
========================= */
.conversation {
    max-height: 450px;
    overflow-y: auto;
    padding: 15px;
    background: #fafafa;
    border-radius: 10px;
    margin-bottom: 20px;
}

.message {
    margin-bottom: 15px;
    padding: 14px 18px;
    border-radius: 12px;
    max-width: 75%;
}

.message-customer {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    margin-right: auto;
}

.message-staff {
    background: #d1ecf1;
    border-left: 4px solid #17a2b8;
    margin-left: auto;
}

.message-sender { font-weight: 700; font-size: 12px; text-transform: uppercase; margin-bottom: 8px; color: #495057; }
.message-text { font-size: 14px; line-height: 1.6; color: #212529; margin-bottom: 8px; }
.message-time { font-size: 11px; color: #6c757d; }

/* =========================
   Footer
========================= */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
    font-size: 13px;
}

/* =========================
   Utility Classes
========================= */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.hidden { display: none; }

/* =========================
   Modals
========================= */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    overflow-y: auto;
}

.modal.active { display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; }

.modal-content {
    background: var(--white);
    border-radius: 12px;
    max-width: 850px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 25px 30px;
    border-bottom: 2px solid #e9ecef;
    background: var(--background);
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 { margin: 0; color: var(--primary-color); font-size: 24px; }
.close-modal {
    background: #e9ecef;
    border: none;
    width: 36px; height: 36px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    color: #495057;
}
.close-modal:hover { background: #dee2e6; }

.modal-body { padding: 30px; }

/* =========================
   Responsive
========================= */
@media (max-width: 768px) {
    .filters { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .nav-tabs { overflow-x: auto; }
}

@media (max-width: 480px) {
    .header h1 { font-size: 20px; }
    .header p { font-size: 12px; }
    .card, .stat-card, .chart-container, .form-section { padding: 20px; }
    .btn { padding: 12px 24px; font-size: 14px; }
    table { font-size: 12px; }
    th, td { padding: 8px; }
}

/* =========================
   Animations
========================= */
.spinner {
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 30px; height: 30px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* =========================
   Print Styles
========================= */
@media print {
    .btn, .filters, .footer { display: none; }
    .card { box-shadow: none; border: 1px solid var(--border); }
}
