/* HighPass Tours CRM - Minimal Lightweight Styling */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2c3e50;
    --secondary: #3498db;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --light: #ecf0f1;
    --border: #bdc3c7;
    --text: #2c3e50;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text);
    background: #f5f7fa;
    line-height: 1.6;
}

.container {
    width: 90%;
    max-width: none;
    margin: 0 auto;
    padding: 0;
}

/* Container inside layout should be full width */
.layout .container {
    width: 100%;
}

/* Global 90% width for all CRM page containers */
.crm-contact-detail,
.crm-contacts-container,
.crm-tickets-container,
.crm-ticket-detail,
.crm-groups-container,
.crm-import-container,
.crm-automation-container,
.crm-campaigns-container,
.crm-campaign-detail,
.crm-campaign-send,
.crm-dashboard {
    width: 90% !important;
    max-width: none !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Header */
header {
    background: #2c3e50;
    color: white;
    padding: 15px 0;
}

header .container {
    width: 90%;
    margin: 0 auto;
}

header h1 {
    font-size: 22px;
    margin-bottom: 4px;
    font-weight: 600;
}

header p {
    font-size: 13px;
    opacity: 0.8;
}

/* =====================================================
   NAVIGATION - Simple Clean Design
   ===================================================== */
.crm-nav {
    background: #f8f9fa;
    padding: 0;
    border-bottom: 1px solid #dee2e6;
}

.nav-container {
    width: 90%;
    margin: 0 auto;
    padding: 0;
}

.nav-menu {
    list-style: none;
    display: flex;
    align-items: stretch;
    margin: 0;
    padding: 0;
}

.nav-item {
    position: relative;
    border-right: 1px solid #dee2e6;
    display: flex;
    align-items: center;
}

.nav-item:first-child {
    border-left: 1px solid #dee2e6;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    color: #495057;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
    height: 100%;
}

.nav-link:hover {
    background: #e9ecef;
    color: #212529;
}

.nav-link.active {
    background: #3498db;
    color: #fff;
}

/* Mobile responsive */
@media (max-width: 1024px) {
    .nav-menu {
        flex-wrap: wrap;
    }
    
    .nav-link {
        padding: 12px 16px;
        font-size: 13px;
    }
}

@media (max-width: 768px) {
    .nav-menu {
        flex-wrap: wrap;
    }
    
    .nav-item {
        flex: 1 1 auto;
        border-bottom: 1px solid #dee2e6;
    }
    
    .nav-link {
        text-align: center;
        padding: 10px 12px;
        font-size: 12px;
    }
}

/* Layout */
.layout {
    width: 90%;
    margin: 0 auto;
    padding: 20px 0;
}

.main {
    background: white;
    border-radius: 4px;
    padding: 25px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

.stat-card {
    background: linear-gradient(135deg, var(--secondary) 0%, #2980b9 100%);
    color: white;
    padding: 20px;
    border-radius: 4px;
    text-align: center;
}

.stat-card h3 {
    font-size: 13px;
    text-transform: uppercase;
    opacity: 0.9;
    margin-bottom: 10px;
}

.stat-card .number {
    font-size: 32px;
    font-weight: bold;
}

.stat-card.pending { background: linear-gradient(135deg, var(--warning) 0%, #e67e22 100%); }
.stat-card.active { background: linear-gradient(135deg, var(--success) 0%, #229954 100%); }
.stat-card.resolved { background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%); }

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

thead {
    background: #f8f9fa;
    border-bottom: 2px solid var(--border);
}

th {
    text-align: left;
    padding: 12px 15px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text);
}

td {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
}

tbody tr:hover {
    background: #f9f9f9;
}

/* Buttons & Links */
.btn {
    display: inline-block;
    padding: 8px 15px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.3s;
    font-weight: 500;
}

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

.btn-primary:hover {
    background: #2980b9;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-secondary {
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--light);
}

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

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

a.link {
    color: var(--secondary);
    text-decoration: none;
    cursor: pointer;
}

a.link:hover {
    text-decoration: underline;
}

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

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 14px;
}

input[type="text"],
input[type="email"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 3px;
    font-family: inherit;
    font-size: 14px;
}

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

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Status Badge */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-pending {
    background: #fff3cd;
    color: #856404;
}

.badge-contacted {
    background: #dbeafe;
    color: #1e40af;
}

.badge-quoted {
    background: #ede9fe;
    color: #5b21b6;
}

.badge-confirmed {
    background: #d1fae5;
    color: #065f46;
}

.badge-cancelled {
    background: #fee2e2;
    color: #991b1b;
}

/* Legacy statuses (backward compat) */
.badge-replied {
    background: #d4edda;
    color: #155724;
}

.badge-resolved {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-booked {
    background: #cce5ff;
    color: #004085;
}

/* Message Thread */
.message-thread {
    margin-top: 20px;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.message {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 15px;
}

.message:last-child {
    border-bottom: none;
}

.message.admin {
    background: #f0f7ff;
}

.message-header {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 5px;
}

.message-time {
    font-size: 12px;
    color: #7f8c8d;
}

.message-body {
    line-height: 1.6;
    color: var(--text);
    word-wrap: break-word;
    padding-bottom: 8px;
}

.message-body iframe {
    width: 100%;
    min-height: 50px;
    height: auto;
    border: none;
    border-radius: 3px;
    background: white;
    overflow: hidden;
}

.message-body.html-content {
    padding: 0;
}

/* Search & Filter */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-bar input {
    flex: 1;
}

.filter-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-group select {
    width: auto;
    flex: 1;
    min-width: 150px;
}

/* Alerts */
.alert {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    border-left: 4px solid;
}

.alert-success {
    background: #d4edda;
    border-left-color: var(--success);
    color: #155724;
}

.alert-error {
    background: #f8d7da;
    border-left-color: var(--danger);
    color: #721c24;
}

.alert-info {
    background: #d1ecf1;
    border-left-color: var(--secondary);
    color: #0c5460;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: #7f8c8d;
}

.empty-state h3 {
    color: var(--text);
    margin-bottom: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-group {
        flex-direction: column;
    }
    
    .filter-group select {
        min-width: auto;
    }
    
    table {
        font-size: 12px;
    }
    
    th, td {
        padding: 8px 10px;
    }
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* =====================================================
   TOM SELECT - SEARCHABLE DROPDOWNS (GLOBAL)
   ===================================================== */
.ts-wrapper {
    width: 100%;
}

.ts-wrapper .ts-control {
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    min-height: 42px;
    box-shadow: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ts-wrapper .ts-control:hover {
    border-color: #8a9dad;
}

.ts-wrapper.focus .ts-control {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.ts-wrapper .ts-control input {
    font-size: 14px;
}

.ts-wrapper .ts-control input::placeholder {
    color: #8a9dad;
}

.ts-dropdown {
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-top: 4px;
    z-index: 10000;
}

.ts-dropdown .ts-dropdown-content {
    max-height: 280px;
    padding: 4px;
}

.ts-dropdown .option {
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.ts-dropdown .option:hover {
    background: #f0f4f8;
}

.ts-dropdown .option.active {
    background: var(--secondary);
    color: white;
}

.ts-dropdown .option.selected {
    background: #e3f2fd;
    color: var(--secondary);
}

.ts-dropdown .option.selected.active {
    background: var(--secondary);
    color: white;
}

.ts-dropdown .no-results {
    padding: 12px;
    text-align: center;
    color: #8a9dad;
    font-size: 13px;
}

.ts-wrapper .ts-control .item {
    background: transparent;
    border: none;
    padding: 0;
    color: var(--text);
    font-size: 14px;
}
