/* ==============================================================
   Global Styles & Reset
   ============================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #25D366;
    --secondary-color: #128C7E;
    --dark-bg: #111B21;
    --light-bg: #F0F2F5;
    --white: #FFFFFF;
    --gray: #8696A0;
    --dark-gray: #3B4A54;
    --sent-bg: #D9FDD3;
    --received-bg: #FFFFFF;
    --border: #E9EDEF;
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    color: #333;
}

/* ==============================================================
   Navigation Bar
   ============================================================== */
.navbar {
    background-color: var(--secondary-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px var(--shadow);
}

.navbar-brand {
    color: var(--white);
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-menu {
    display: flex;
    gap: 1.5rem;
}

.navbar-menu a {
    color: var(--white);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background 0.3s;
}

.navbar-menu a:hover,
.navbar-menu a.active {
    background-color: rgba(255, 255, 255, 0.2);
}

/* ==============================================================
   Container & Layout
   ============================================================== */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.page-title {
    font-size: 2rem;
    color: var(--secondary-color);
    margin-bottom: 1.5rem;
}

/* ==============================================================
   Dashboard Stats
   ============================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px var(--shadow);
    text-align: center;
}

.stat-card .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.stat-card .value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
}

.stat-card .label {
    color: var(--gray);
    font-size: 1rem;
}

/* ==============================================================
   Chat Interface (WhatsApp Style)
   ============================================================== */
.chat-container {
    display: flex;
    height: calc(100vh - 140px);
    background: var(--white);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
}

/* Sidebar */
.chat-sidebar {
    width: 350px;
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    background: var(--secondary-color);
    color: var(--white);
    padding: 1rem;
    font-weight: bold;
    font-size: 1.2rem;
}

.sidebar-search {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-search input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    outline: none;
}

.user-list {
    flex: 1;
    overflow-y: auto;
}

.user-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.user-item:hover {
    background: var(--light-bg);
}

.user-item.active {
    background: var(--light-bg);
}

.user-item .user-name {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.user-item .user-phone {
    color: var(--gray);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.user-item .last-message {
    color: var(--gray);
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #E5DDD5;
}

.chat-header {
    background: var(--secondary-color);
    color: var(--white);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-header .chat-user-name {
    font-weight: bold;
    font-size: 1.1rem;
}

.chat-header .chat-user-phone {
    font-size: 0.85rem;
    opacity: 0.8;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message {
    max-width: 60%;
    padding: 0.75rem;
    border-radius: 8px;
    position: relative;
    word-wrap: break-word;
}

.message.sent {
    background: var(--sent-bg);
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.message.received {
    background: var(--received-bg);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.message-content {
    margin-bottom: 0.25rem;
}

.message-time {
    font-size: 0.7rem;
    color: var(--gray);
    text-align: right;
}

.message.sent .message-time {
    color: #667781;
}

.chat-input {
    background: var(--white);
    padding: 1rem;
    display: flex;
    gap: 0.5rem;
    border-top: 1px solid var(--border);
}

.chat-input input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 25px;
    outline: none;
    font-size: 0.95rem;
}

.chat-input button {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

.chat-input button:hover {
    background: var(--secondary-color);
}

.chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray);
    font-size: 1.2rem;
}

/* ==============================================================
   Forms
   ============================================================== */
.form-container {
    background: var(--white);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px var(--shadow);
    max-width: 600px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark-gray);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 1rem;
    outline: none;
    transition: border 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* ==============================================================
   Buttons
   ============================================================== */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--secondary-color);
}

.btn-secondary {
    background: var(--gray);
    color: var(--white);
}

.btn-secondary:hover {
    background: var(--dark-gray);
}

.btn-danger {
    background: #DC3545;
    color: var(--white);
}

.btn-danger:hover {
    background: #C82333;
}

.btn-block {
    width: 100%;
}

/* ==============================================================
   Table
   ============================================================== */
.table-container {
    background: var(--white);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--secondary-color);
    color: var(--white);
}

thead th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

tbody tr:hover {
    background: var(--light-bg);
}

tbody td {
    padding: 1rem;
}

/* ==============================================================
   Bulk Sender
   ============================================================== */
.bulk-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.contact-row {
    display: grid;
    grid-template-columns: 2fr 2fr 2fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

.contact-row input {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    outline: none;
}

/* ==============================================================
   Alert Messages
   ============================================================== */
.alert {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #D4EDDA;
    color: #155724;
    border: 1px solid #C3E6CB;
}

.alert-error {
    background: #F8D7DA;
    color: #721C24;
    border: 1px solid #F5C6CB;
}

.alert-info {
    background: #D1ECF1;
    color: #0C5460;
    border: 1px solid #BEE5EB;
}

/* ==============================================================
   Loading Spinner
   ============================================================== */
.spinner {
    border: 4px solid var(--border);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==============================================================
   Responsive Design
   ============================================================== */
@media (max-width: 768px) {
    .chat-sidebar {
        width: 100%;
    }
    
    .chat-main {
        display: none;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .navbar-menu {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ==============================================================
   Utility Classes
   ============================================================== */
.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.hidden {
    display: none;
}
