/* ============================================
   CSS Reset
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.5;
    color: #333;
    background-color: #36393f;
    min-height: 100vh;
}

/* ============================================
   Root Container
   ============================================ */
#app {
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

#root {
    width: 100%;
    height: 100%;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
}

a {
    color: #5865f2;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #4752c4;
}

/* ============================================
   Form Elements
   ============================================ */
input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid #202225;
    border-radius: 4px;
    background-color: #202225;
    color: #dcddde;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: #5865f2;
    box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.2);
}

input::placeholder,
textarea::placeholder {
    color: #72767d;
}

button {
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

button:active {
    transform: scale(0.98);
}

/* ============================================
   Utility Classes
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.hidden { display: none !important; }

/* ============================================
   Button Variants
   ============================================ */
.btn-primary {
    background-color: #5865f2;
    color: white;
}

.btn-primary:hover {
    background-color: #4752c4;
}

.btn-secondary {
    background-color: #4f545c;
    color: white;
}

.btn-secondary:hover {
    background-color: #40444b;
}

.btn-danger {
    background-color: #ed4245;
    color: white;
}

.btn-danger:hover {
    background-color: #c93b3e;
}

.btn-ghost {
    background-color: transparent;
    color: #dcddde;
}

.btn-ghost:hover {
    background-color: rgba(79, 84, 92, 0.3);
}

/* ============================================
   Card Component
   ============================================ */
.card {
    background-color: #2f3136;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ============================================
   Loading Spinner
   ============================================ */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #5865f2;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .container {
        padding: 0 0.75rem;
    }
}

/* ============================================
   View-specific Styles
   ============================================ */

/* Login/Register View */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #36393f 0%, #2f3136 100%);
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

.auth-title {
    text-align: center;
    color: white;
    margin-bottom: 2rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-form input {
    margin-bottom: 0.5rem;
}

.auth-form button {
    margin-top: 0.5rem;
}

.auth-toggle {
    text-align: center;
    margin-top: 1rem;
    color: #b9bbbe;
}

.auth-toggle a {
    color: #5865f2;
}

/* Dashboard View */
.dashboard-container {
    display: flex;
    height: 100vh;
}

.dashboard-sidebar {
    width: 280px;
    background-color: #202225;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #121212;
}

.dashboard-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #36393f;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #121212;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #b9bbbe;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    margin-bottom: 0.25rem;
}

.nav-item:hover {
    background-color: rgba(79, 84, 92, 0.3);
    color: white;
}

.nav-item.active {
    background-color: rgba(88, 101, 242, 0.3);
    color: white;
}

.nav-item-icon {
    margin-right: 0.75rem;
    font-size: 1.25rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid #121212;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #5865f2;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.user-info {
    flex: 1;
}

.user-name {
    color: white;
    font-weight: 500;
}

.user-status {
    color: #b9bbbe;
    font-size: 0.875rem;
}

.main-header {
    padding: 1rem 1.5rem;
    background-color: #2f3136;
    border-bottom: 1px solid #121212;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.main-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

/* Room List */
.room-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.room-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: #2f3136;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.room-item:hover {
    background-color: #40444b;
}

.room-item.active {
    background-color: rgba(88, 101, 242, 0.2);
    border-left: 3px solid #5865f2;
}

.room-name {
    color: white;
    font-weight: 500;
}

.room-unread {
    margin-left: auto;
    background-color: #ed4245;
    color: white;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
}

/* Friend List */
.friend-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.friend-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: #2f3136;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.friend-item:hover {
    background-color: #40444b;
}

.friend-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #5865f2;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    margin-right: 0.75rem;
}

.friend-info {
    flex: 1;
}

.friend-name {
    color: white;
    font-weight: 500;
}

.friend-status {
    color: #b9bbbe;
    font-size: 0.875rem;
}

.status-online {
    color: #43b581;
}

.status-offline {
    color: #747f8d;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #b9bbbe;
    text-align: center;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1.125rem;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: #36393f;
    min-width: 400px;
    padding: 1.5rem;
    position: relative;
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.24);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    margin: 0;
    color: white;
}

.modal-body label {
    color: #b9bbbe;
    font-size: 0.875rem;
    font-weight: 500;
}

/* ============================================
   Toast Notifications
   ============================================ */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 280px;
    max-width: 420px;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    color: white;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
}

.toast-visible {
    opacity: 1;
    transform: translateX(0);
}

.toast-exit {
    opacity: 0;
    transform: translateX(100%);
}

.toast-success {
    background-color: #2d7d46;
}

.toast-error {
    background-color: #d83c3e;
}

.toast-warning {
    background-color: #c27c0e;
}

.toast-info {
    background-color: #4752c4;
}

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.25rem;
    flex-shrink: 0;
}

.toast-close:hover {
    color: white;
}

/* ============================================
   Loading Spinner (enhanced)
   ============================================ */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #5865f2;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 2rem auto;
}

