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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0a0a0a;
    min-height: 100vh;
    color: #e0e0e0;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: #1a1a1a;
    padding: 40px;
    border-radius: 8px;
    border: 1px solid #333;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    color: #fff;
    margin-bottom: 10px;
    font-size: 24px;
    font-weight: 600;
}

.subtitle {
    color: #999;
    margin-bottom: 30px;
    font-size: 12px;
}

.login-box input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 12px;
    color: #fff;
    transition: border-color 0.3s;
}

.login-box input:focus {
    outline: none;
    border-color: #666;
}

.login-box button {
    width: 100%;
    padding: 12px;
    background: #fff;
    color: #0a0a0a;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-box button:hover {
    background: #e0e0e0;
}

.login-box button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.error {
    background: #2a1a1a;
    color: #ff6b6b;
    padding: 12px;
    border-radius: 4px;
    margin-top: 15px;
    border: 1px solid #442;
}

.hidden {
    display: none;
}

/* Dashboard */
.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.dashboard-header {
    background: #0a0a0a;
    padding: 10px 30px;
    border-bottom: 1px solid #1a1a1a;
    margin: -20px -20px 15px -20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-header h1 {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.last-updated {
    color: #666;
    font-size: 11px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.last-updated #updateTime {
    color: #999;
}

.logout-btn {
    padding: 0;
    background: transparent;
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 400;
    font-size: 11px;
    transition: color 0.2s;
}

.logout-btn:hover {
    color: #999;
}

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

.stat-card {
    background: #1a1a1a;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #333;
    text-align: center;
}

.stat-card h3 {
    color: #999;
    font-size: 11px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.stat-card p {
    color: #fff;
    font-size: 28px;
    font-weight: 700;
}

.messages-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    min-height: 400px;
}

.message-card {
    background: #1a1a1a;
    border: 1px solid #333;
    padding: 12px;
    border-radius: 8px;
    transition: border-color 0.2s, background 0.2s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.message-card:hover {
    border-color: #444;
    background: #1f1f1f;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #2a2a2a;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.read-btn {
    width: 18px;
    height: 18px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 3px;
    color: #4a9eff;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.read-btn:hover {
    background: #333;
    border-color: #4a9eff;
    transform: scale(1.1);
}

.sender {
    font-weight: 600;
    color: #fff;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timestamp {
    color: #666;
    font-size: 10px;
    font-weight: 400;
}

.message-content {
    color: #e0e0e0;
    line-height: 1.7;
    word-wrap: break-word;
    font-size: 12px;
}

.message-content[dir="rtl"] {
    text-align: right;
}

.message-content[dir="ltr"] {
    text-align: left;
}

.expand-btn {
    color: #4a9eff;
    cursor: pointer;
    font-weight: 500;
    margin-left: 5px;
    user-select: none;
}

.expand-btn:hover {
    color: #6bb0ff;
    text-decoration: underline;
}

.chat-info, .media-info {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #2a2a2a;
    color: #999;
    font-size: 10px;
}

.media-info a {
    color: #fff;
    text-decoration: none;
    font-weight: 500;
}

.media-info a:hover {
    text-decoration: underline;
}

.loading, .no-messages {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 14px;
}

.error {
    background: #2a1a1a;
    color: #ff6b6b;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #442;
    line-height: 1.6;
}

.error strong {
    display: block;
    margin-bottom: 8px;
    font-size: 15px;
}

.error small {
    display: block;
    margin-top: 8px;
    color: #cc5555;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    padding: 15px;
    background: #1a1a1a;
    border-radius: 6px;
    border: 1px solid #333;
}

.pagination button {
    padding: 8px 20px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    color: #fff;
    font-size: 12px;
    transition: background 0.2s, border-color 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: #333;
    border-color: #555;
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-info {
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    padding: 0 10px;
    min-width: 80px;
    text-align: center;
}

@media (max-width: 768px) {
    .messages-container {
        grid-template-columns: 1fr;
    }
    
    .dashboard-header {
        flex-direction: column;
        gap: 15px;
    }
    
    .dashboard-header h1 {
        font-size: 16px;
    }
    
    .message-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .message-card {
        padding: 15px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .messages-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1025px) and (max-width: 1366px) {
    .messages-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #2a2a2a;
}

.modal-header h3 {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.modal-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-copy {
    background: transparent;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.2s;
    line-height: 1;
}

.modal-copy:hover {
    color: #4a9eff;
    transform: scale(1.1);
}

.modal-close {
    background: transparent;
    border: none;
    color: #999;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    line-height: 1;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    color: #e0e0e0;
    line-height: 1.7;
    font-size: 13px;
    word-wrap: break-word;
}

.modal-body[dir="rtl"] {
    text-align: right;
}

.modal-body[dir="ltr"] {
    text-align: left;
}