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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

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

/* Header */
header {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
    color: #25D366;
    margin-bottom: 10px;
}

.user-info {
    color: #666;
}

.breadcrumb {
    margin-top: 10px;
    color: #666;
}

.breadcrumb a {
    color: #25D366;
    text-decoration: none;
}

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

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

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
    color: #666;
    margin-bottom: 10px;
    font-size: 14px;
    text-transform: uppercase;
}

.stat-number {
    font-size: 32px;
    font-weight: bold;
    color: #25D366;
}

.stat-text {
    font-size: 18px;
    color: #333;
    text-transform: capitalize;
}

/* Navigation */
.main-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.nav-card {
    background: white;
    border-radius: 8px;
    padding: 30px;
    text-decoration: none;
    color: #333;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.nav-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.nav-card h2 {
    color: #25D366;
    margin-bottom: 10px;
    font-size: 24px;
}

.nav-card p {
    color: #666;
    font-size: 14px;
}

/* Conversations List */
.conversations-list {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.conversation-item {
    display: block;
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none;
    color: #333;
    transition: background-color 0.2s;
}

.conversation-item:hover {
    background-color: #f8f9fa;
}

.conversation-item:last-child {
    border-bottom: none;
}

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

.conversation-header h3 {
    font-size: 16px;
    color: #333;
    margin: 0;
}

/* Conversation badges */
.conversation-badges {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.4;
    font-weight: 600;
    background: #f0f2f5;
    color: #333;
}

.badge.group {
    background: #e7faef;
    color: #0b3d2c;
}

.badge.unread {
    background: #fff3cd;
    color: #5c3b00;
}

.timestamp {
    font-size: 12px;
    color: #999;
}

.conversation-meta {
    font-size: 14px;
    color: #666;
}

.message-count {
    background: #e8f5e8;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

/* Messages */
.messages-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.message {
    margin-bottom: 15px;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #ddd;
}

.message.customer {
    border-left-color: #25D366;
    background: #f0f8f0;
}

.message.siu_employee {
    border-left-color: #007acc;
    background: #f0f6ff;
}

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

.sender-name {
    font-weight: bold;
    color: #333;
}

.message-body p {
    margin: 0;
    white-space: pre-wrap;
}

.mention {
    background: #fff3cd;
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.reactions {
    margin-top: 6px;
}

.reaction-badge {
    display: inline-block;
    margin-right: 4px;
    padding: 2px 6px;
    background: #f0f2f5;
    border-radius: 12px;
    font-size: 16px;
}

.attachments {
    margin-top: 10px;
}

.attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 5px;
}

/* Compact, media-friendly layout for image attachments */
.attachment.image {
    background: transparent;
    padding: 0;
}

.attachment-image {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.attachment-video,
.attachment-audio {
    width: 100%;
    max-width: 480px;
}

.attachment-icon {
    font-size: 16px;
}

.attachment-name {
    font-weight: 500;
    flex: 1;
}

.attachment-type {
    font-size: 12px;
    color: #666;
}

/* Attachments Grid */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn.active,
.filter-btn:hover {
    background: #25D366;
    color: white;
    border-color: #25D366;
}

.attachments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.attachment-card {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.attachment-card:hover {
    transform: translateY(-2px);
}

.attachment-preview {
    text-align: center;
    margin-bottom: 15px;
}

.file-icon {
    font-size: 48px;
    display: block;
}

.attachment-info h4 {
    color: #333;
    margin-bottom: 8px;
    font-size: 14px;
}

.attachment-info p {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.mime-type {
    font-family: monospace;
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Pagination */
.pagination {
    text-align: center;
    margin-top: 30px;
}

.btn-primary {
    background: #25D366;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background: #20bc5a;
}

/* ---------- Shared components & utilities ---------- */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn-success {
    background-color: #28a745;
    color: #fff;
}

.btn-success:hover {
    background-color: #1e7e34;
}

.btn-secondary {
    background-color: #6c757d;
    color: #fff;
}

.btn-secondary:hover {
    background-color: #545b62;
}

.btn-danger {
    background-color: #dc3545;
    color: #fff;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.hidden {
    display: none !important;
}

.inline-form {
    display: inline;
}

/* Auth pages */
body.centered-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f5f5f5;
}

.login-form,
.logout-form {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 300px;
}

.login-form {
    width: 400px;
}

.login-form h2 {
    margin-top: 0;
    text-align: center;
    color: #25D366;
}

.logout-form h2 {
    margin-top: 0;
    color: #333;
}

.logout-form p {
    color: #666;
    margin-bottom: 2rem;
}

.button-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.error-message {
    color: #c62828;
    background: #ffebee;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 1rem;
    text-align: center;
}

.success-message {
    color: #2e7d32;
    background: #e8f5e8;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 1rem;
    text-align: center;
}

.help-text {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

/* Notification section (homepage) */
.notification-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    border: 2px dashed #ddd;
    text-align: center;
}

.status-message {
    margin: 1rem 0;
    padding: 0.75rem;
    border-radius: 4px;
    display: none;
}

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

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

.status-info {
    background: #cce7ff;
    color: #004085;
    border: 1px solid #b8daff;
}

#install-pwa {
    background-color: #17a2b8;
    color: white;
}

#install-pwa:hover {
    background-color: #138496;
}

/* Notifications dashboard */
.notifications-page {
    margin: 20px;
}

.notifications-wrapper {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.notification {
    border-bottom: 1px solid #eee;
    padding: 15px;
}

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

.status-pending {
    color: #ffb74d;
}

.status-sent {
    color: #66bb6a;
}

.status-failed {
    color: #ef5350;
}

.priority-high {
    font-weight: bold;
}

.timestamp {
    color: #666;
    font-size: 0.9em;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
}

.error-text {
    color: #ef5350;
    font-size: 0.9em;
    margin-top: 5px;
}

/* Admin notifications page blocks */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

header.page-header {
    margin-bottom: 2rem;
    text-align: center;
}

.user-info span {
    margin: 0 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #007bff;
}

.stat-label {
    color: #666;
    margin-top: 0.5rem;
}

.notifications-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.notification-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #007bff;
}

.notification-info {
    flex: 1;
}

.notification-title {
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.notification-content {
    color: #666;
    margin-bottom: 0.5rem;
}

.priority-badge {
    background: #ffc107;
    color: #212529;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.priority-badge.high {
    background: #dc3545;
    color: white;
}

.retry-count {
    color: #dc3545;
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

.notification-controls {
    display: flex;
    gap: 0.5rem;
}

.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

@media (max-width: 768px) {
    header.page-header {
        text-align: center;
    }

    .breadcrumb {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .notification-item {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .notification-controls {
        justify-content: center;
    }
}

/* Manual dark mode toggle */
body.dark-mode {
    background-color: #0e1117;
    color: #e6edf3;
}

body.dark-mode header {
    background: #161b22;
    box-shadow: none;
}

body.dark-mode .user-info,
body.dark-mode .breadcrumb,
body.dark-mode .conversation-meta,
body.dark-mode .attachment-info p,
body.dark-mode .timestamp {
    color: #9da7b3;
}

body.dark-mode .breadcrumb a {
    color: #4ae28a;
}

body.dark-mode .breadcrumb a:hover {
    text-decoration: underline;
}

body.dark-mode .stat-card,
body.dark-mode .nav-card,
body.dark-mode .conversations-list,
body.dark-mode .messages-container,
body.dark-mode .attachment-card,
body.dark-mode .notification-section,
body.dark-mode .notifications-wrapper {
    background: #161b22;
    color: #e6edf3;
    box-shadow: none;
    border-color: #2a2f3a;
}

body.dark-mode .nav-card {
    color: #e6edf3;
}

body.dark-mode .nav-card p {
    color: #9da7b3;
}

body.dark-mode .conversation-item {
    color: #e6edf3;
    border-bottom-color: #222833;
}

body.dark-mode .conversation-item:hover {
    background-color: #0f141b;
}

body.dark-mode .badge {
    background: #1f242d;
    color: #e6edf3;
    border: 1px solid #2a2f3a;
}

body.dark-mode .badge.group {
    background: rgba(37, 211, 102, 0.18);
    color: #b7f5bf;
    border-color: rgba(37, 211, 102, 0.24);
}

body.dark-mode .badge.unread {
    background: rgba(255, 183, 77, 0.2);
    color: #ffd391;
    border-color: rgba(255, 183, 77, 0.28);
}

body.dark-mode .message-count {
    background: rgba(37, 211, 102, 0.15);
    color: #b7f5bf;
}

body.dark-mode .message {
    border-left-color: #2a2f3a;
    background: #10151b;
}

body.dark-mode .message.customer {
    border-left-color: #25D366;
    background: rgba(37, 211, 102, 0.08);
}

body.dark-mode .message.siu_employee {
    border-left-color: #2aa8ff;
    background: rgba(42, 168, 255, 0.1);
}

body.dark-mode .sender-name {
    color: #e6edf3;
}

body.dark-mode .reaction-badge {
    background: #1f242d;
}

body.dark-mode .attachments .attachment {
    background: #0f141b;
}

body.dark-mode .mime-type {
    background: #0f141b;
    color: #9da7b3;
}

body.dark-mode .filter-btn {
    background: #0f141b;
    border-color: #2a2f3a;
    color: #e6edf3;
}

body.dark-mode .filter-btn.active,
body.dark-mode .filter-btn:hover {
    background: #25D366;
    color: #0e1117;
    border-color: #25D366;
}

body.dark-mode .error-message {
    background: rgba(239, 83, 80, 0.15);
    color: #ff9b99;
}

body.dark-mode .success-message {
    background: rgba(102, 187, 106, 0.15);
    color: #b7f5bf;
}

body.dark-mode .login-form,
body.dark-mode .logout-form {
    background: #161b22;
    box-shadow: none;
}

body.dark-mode.centered-page {
    background-color: #0e1117;
}

body.dark-mode .status-success {
    background: rgba(102, 187, 106, 0.15);
    color: #b7f5bf;
    border-color: #285c31;
}

body.dark-mode .status-error {
    background: rgba(239, 83, 80, 0.15);
    color: #ff9b99;
    border-color: #6d2b2a;
}

body.dark-mode .status-info {
    background: rgba(100, 181, 246, 0.15);
    color: #9bd1ff;
    border-color: #1a3f5c;
}

body.dark-mode .notification-item {
    background: #0f141b;
    border-left-color: #4ae28a;
}

body.dark-mode header.page-header {
    color: #e6edf3;
}

/* ---------- Dark mode overrides ---------- */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #0e1117;
        color: #e6edf3;
    }

    header {
        background: #161b22;
        box-shadow: none;
    }

    .user-info,
    .breadcrumb,
    .conversation-meta,
    .attachment-info p,
    .timestamp {
        color: #9da7b3;
    }

    .breadcrumb a {
        color: #4ae28a;
    }

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

    .stat-card,
    .nav-card,
    .conversations-list,
    .messages-container,
    .attachment-card,
    .notification-section,
    .notifications-wrapper {
        background: #161b22;
        color: #e6edf3;
        box-shadow: none;
        border-color: #2a2f3a;
    }

    .nav-card {
        color: #e6edf3;
    }

    .nav-card p {
        color: #9da7b3;
    }

    .conversation-item {
        color: #e6edf3;
        border-bottom-color: #222833;
    }

    .conversation-item:hover {
        background-color: #0f141b;
    }

    .badge {
        background: #1f242d;
        color: #e6edf3;
        border: 1px solid #2a2f3a;
    }

    .badge.group {
        background: rgba(37, 211, 102, 0.18);
        color: #b7f5bf;
        border-color: rgba(37, 211, 102, 0.24);
    }

    .badge.unread {
        background: rgba(255, 183, 77, 0.2);
        color: #ffd391;
        border-color: rgba(255, 183, 77, 0.28);
    }

    .message-count {
        background: rgba(37, 211, 102, 0.15);
        color: #b7f5bf;
    }

    .message {
        border-left-color: #2a2f3a;
        background: #10151b;
    }

    .message.customer {
        border-left-color: #25D366;
        background: rgba(37, 211, 102, 0.08);
    }

    .message.siu_employee {
        border-left-color: #2aa8ff;
        background: rgba(42, 168, 255, 0.10);
    }

    .sender-name {
        color: #e6edf3;
    }

    .reaction-badge {
        background: #1f242d;
    }

    .attachments .attachment {
        background: #0f141b;
    }

    .mime-type {
        background: #0f141b;
        color: #9da7b3;
    }

    .filter-btn {
        background: #0f141b;
        border-color: #2a2f3a;
        color: #e6edf3;
    }

    .filter-btn.active,
    .filter-btn:hover {
        background: #25D366;
        color: #0e1117;
        border-color: #25D366;
    }

    .error-message {
        background: rgba(239, 83, 80, 0.15);
        color: #ff9b99;
    }

    .success-message {
        background: rgba(102, 187, 106, 0.15);
        color: #b7f5bf;
    }

    .login-form,
    .logout-form {
        background: #161b22;
        box-shadow: none;
    }

    body.centered-page {
        background-color: #0e1117;
    }

    .status-success {
        background: rgba(102, 187, 106, 0.15);
        color: #b7f5bf;
        border-color: #285c31;
    }

    .status-error {
        background: rgba(239, 83, 80, 0.15);
        color: #ff9b99;
        border-color: #6d2b2a;
    }

    .status-info {
        background: rgba(100, 181, 246, 0.15);
        color: #9bd1ff;
        border-color: #1a3f5c;
    }

    .notification-item {
        background: #0f141b;
        border-left-color: #4ae28a;
    }

    header.page-header {
        color: #e6edf3;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .main-nav {
        grid-template-columns: 1fr;
    }

    .conversation-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .attachments-grid {
        grid-template-columns: 1fr;
    }
}
