/* Windows 95 Theme CSS - Complete SPA Styling */

:root {
    --win95-gray: #c0c0c0;
    --win95-dark-gray: #808080;
    --win95-white: #ffffff;
    --win95-black: #000000;
    --win95-blue: #000080;
    --win95-light-blue: #1084d0;
    --win95-desktop: #008080;
    --win95-green: #008000;
    --win95-red: #ff0000;
}

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

body {
    font-family: 'MS Sans Serif', 'Tahoma', Arial, sans-serif;
    font-size: 11px;
    background-color: var(--win95-desktop);
    color: var(--win95-black);
    overflow: hidden;
}

/* =========================
   WINDOW COMPONENTS
   ========================= */

.window {
    background-color: var(--win95-gray);
    border-top: 2px solid #ffffff;
    border-left: 2px solid #ffffff;
    border-right: 2px solid #000000;
    border-bottom: 2px solid #000000;
    box-shadow: 1px 1px 0 1px rgba(0, 0, 0, 0.2);
}

.title-bar {
    background: linear-gradient(to right, var(--win95-blue), var(--win95-light-blue));
    color: var(--win95-white);
    padding: 3px 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: default;
    user-select: none;
}

.title-bar-text {
    font-weight: bold;
    font-size: 11px;
    flex: 1;
}

.title-bar-controls {
    display: flex;
    gap: 2px;
}

.title-bar-controls button {
    width: 16px;
    height: 14px;
    padding: 0;
    font-size: 8px;
    background-color: var(--win95-gray);
    border-top: 1px solid #ffffff;
    border-left: 1px solid #ffffff;
    border-right: 1px solid #000000;
    border-bottom: 1px solid #000000;
    color: var(--win95-black);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.title-bar-controls button:active:not(:disabled) {
    border-top: 1px solid #000000;
    border-left: 1px solid #000000;
    border-right: 1px solid #ffffff;
    border-bottom: 1px solid #ffffff;
}

.title-bar-controls button:disabled {
    color: var(--win95-dark-gray);
}

.window-body {
    padding: 10px;
    background-color: var(--win95-gray);
}

/* =========================
   BUTTONS & INPUTS
   ========================= */

button, .button {
    background-color: var(--win95-gray);
    border-top: 2px solid #ffffff;
    border-left: 2px solid #ffffff;
    border-right: 2px solid #000000;
    border-bottom: 2px solid #000000;
    padding: 4px 12px;
    font-family: 'MS Sans Serif', 'Tahoma', Arial, sans-serif;
    font-size: 11px;
    cursor: pointer;
    min-width: 75px;
}

button:hover:not(:disabled) {
    background-color: #d4d4d4;
}

button:active:not(:disabled) {
    border-top: 2px solid #000000;
    border-left: 2px solid #000000;
    border-right: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
    padding: 5px 11px 3px 13px;
}

button:disabled {
    color: var(--win95-dark-gray);
    cursor: not-allowed;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="file"],
textarea {
    border-top: 2px solid #000000;
    border-left: 2px solid #000000;
    border-right: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
    background-color: var(--win95-white);
    padding: 3px 4px;
    font-family: 'MS Sans Serif', 'Tahoma', Arial, sans-serif;
    font-size: 11px;
}

textarea {
    resize: vertical;
}

select {
    border-top: 2px solid #000000;
    border-left: 2px solid #000000;
    border-right: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
    background-color: var(--win95-white);
    padding: 2px;
    font-family: 'MS Sans Serif', 'Tahoma', Arial, sans-serif;
    font-size: 11px;
}

.field-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

.field-row label {
    width: 140px;
    text-align: right;
}

.field-row input,
.field-row select,
.field-row textarea {
    flex: 1;
}

/* =========================
   TABS
   ========================= */

menu[role="tablist"] {
    display: flex;
    padding: 0;
    margin: 0;
    list-style: none;
    border-bottom: 2px solid var(--win95-dark-gray);
}

menu[role="tablist"] button {
    padding: 4px 12px;
    background-color: var(--win95-gray);
    border-top: 2px solid #ffffff;
    border-left: 2px solid #ffffff;
    border-right: 2px solid #808080;
    border-bottom: none;
    cursor: pointer;
    margin-right: 2px;
    min-width: auto;
}

menu[role="tablist"] button.active {
    background-color: var(--win95-gray);
    border-bottom: 2px solid var(--win95-gray);
    margin-bottom: -2px;
    padding-bottom: 6px;
}

menu[role="tablist"] button:hover:not(.active) {
    background-color: #d4d4d4;
}

.tab-content {
    display: none;
    padding: 10px 0;
}

.tab-content.active {
    display: block;
}

.subtab-content {
    display: none;
    padding: 15px 0;
}

.subtab-content.active {
    display: block;
}

/* =========================
   AUTH SCREEN
   ========================= */

.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    background-color: var(--win95-desktop);
}

.auth-container .window {
    width: 500px;
}

/* =========================
   APP SCREEN
   ========================= */

.app-screen {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--win95-desktop);
    padding: 20px;
}

.app-container {
    width: 100%;
    height: 100%;
    max-width: 1400px;
}

.main-window {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.menu-bar {
    background-color: var(--win95-gray);
    padding: 2px;
    border-bottom: 2px solid var(--win95-dark-gray);
}

.main-tabs {
    border-bottom: none;
}

.app-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

/* =========================
   SECTIONS
   ========================= */

.section {
    display: none;
    height: 100%;
    overflow: auto;
    padding: 10px;
}

.section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px groove var(--win95-dark-gray);
}

.section-header h2 {
    font-size: 13px;
    font-weight: bold;
}

.search-bar {
    flex: 1;
    max-width: 400px;
    margin-left: 20px;
}

.search-bar input {
    width: 100%;
}

/* =========================
   CHAT LAYOUT
   ========================= */

.chat-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 10px;
    height: calc(100vh - 160px);
}

.sidebar {
    background-color: var(--win95-white);
    border-top: 2px solid #000000;
    border-left: 2px solid #000000;
    border-right: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    background-color: var(--win95-gray);
    padding: 5px 8px;
    border-bottom: 2px solid var(--win95-dark-gray);
}

.sidebar-header h3 {
    font-size: 11px;
    font-weight: bold;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-list-item {
    padding: 8px;
    border-bottom: 1px solid #d4d4d4;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-list-item:hover {
    background-color: #e0e0e0;
}

.chat-list-item.active {
    background-color: var(--win95-blue);
    color: var(--win95-white);
}

.empty-state {
    padding: 20px;
    text-align: center;
    color: var(--win95-dark-gray);
}

.chat-main {
    background-color: var(--win95-white);
    border-top: 2px solid #000000;
    border-left: 2px solid #000000;
    border-right: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
    display: flex;
    flex-direction: column;
    height: 100%;  /* Tomar toda la altura disponible */
    overflow: hidden;  /* Prevenir scroll aquí */
}

.empty-chat-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--win95-dark-gray);
    text-align: center;
    font-size: 12px;
}

.active-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;  /* Prevenir scroll en el contenedor principal */
}

.chat-header {
    background-color: var(--win95-gray);
    border-bottom: 2px groove var(--win95-dark-gray);
    padding: 8px;
    flex-shrink: 0;  /* No permitir que se encoja */
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-info h3 {
    font-size: 12px;
    margin: 0;
}

.status-text {
    font-size: 9px;
    color: var(--win95-green);
}

.status-text.offline {
    color: var(--win95-dark-gray);
}

.avatar-small {
    width: 32px;
    height: 32px;
    border: 1px solid var(--win95-black);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;  /* Prevenir scroll horizontal */
    padding: 10px;
    background-color: var(--win95-white);
    min-height: 0;  /* CRÍTICO: Permitir que flex funcione correctamente */
}

.message {
    margin-bottom: 12px;
    padding: 5px;
}

.message-sender {
    font-weight: bold;
    color: var(--win95-blue);
    font-size: 11px;
}

.message-time {
    font-size: 9px;
    color: var(--win95-dark-gray);
    margin-left: 5px;
}

.message-content {
    margin-top: 3px;
    font-size: 11px;
    word-wrap: break-word;
}

.message.own {
    text-align: right;
}

.message.own .message-sender {
    color: var(--win95-green);
}

.message img {
    max-width: 300px;
    max-height: 300px;
    border-radius: 4px;
    margin-top: 4px;
    cursor: pointer;
    display: block;
    border: 2px solid #000;
    background: #fff;
}

.message.own img {
    margin-left: auto;
    margin-right: 0;
}

.message:not(.own) img {
    margin-left: 0;
    margin-right: auto;
}

#typing-indicator {
    flex-shrink: 0;  /* No permitir que se encoja */
    padding: 8px;
    font-size: 10px;
    color: #808080;
    font-style: italic;
    background-color: var(--win95-white);
    border-top: 1px solid #d4d4d4;
}

#image-preview-container {
    flex-shrink: 0;  /* No permitir que se encoja */
    padding: 8px;
    background: #c0c0c0;
    border-top: 2px solid #808080;
}

.chat-input-area {
    background-color: var(--win95-gray);
    border-top: 2px groove var(--win95-dark-gray);
    padding: 8px;
    flex-shrink: 0;  /* No permitir que se encoja */
}

.chat-input-area form {
    display: flex;
    gap: 5px;
}

.chat-input-area input {
    flex: 1;
}

.chat-input-area button {
    min-width: 60px;
}

/* =========================
   USERS & FRIENDS GRIDS
   ========================= */

.users-grid,
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 10px;
    padding: 10px 0;
}

.user-card,
.group-card {
    background-color: var(--win95-white);
    border-top: 2px solid #ffffff;
    border-left: 2px solid #ffffff;
    border-right: 2px solid #808080;
    border-bottom: 2px solid #808080;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-card-avatar,
.group-card-avatar {
    width: 48px;
    height: 48px;
    border: 1px solid var(--win95-black);
    flex-shrink: 0;
}

.user-card-info,
.group-card-info {
    flex: 1;
    min-width: 0;
}

.user-card-name,
.group-card-name {
    font-weight: bold;
    font-size: 11px;
    margin-bottom: 3px;
}

.user-card-status,
.group-card-description {
    font-size: 9px;
    color: var(--win95-dark-gray);
}

.user-card-status.online {
    color: var(--win95-green);
}

.user-card-actions,
.group-card-actions {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.user-card-actions button,
.group-card-actions button {
    min-width: 70px;
    padding: 3px 8px;
    font-size: 10px;
}

/* =========================
   PROFILE SECTION
   ========================= */

.profile-container {
    padding: 20px;
    max-width: 600px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: var(--win95-white);
    border-top: 2px solid #000000;
    border-left: 2px solid #000000;
    border-right: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
}

.avatar-large {
    width: 100px;
    height: 100px;
    border: 2px solid var(--win95-black);
    flex-shrink: 0;
}

.profile-info h2 {
    font-size: 14px;
    margin-bottom: 5px;
}

.profile-info p {
    font-size: 11px;
    color: var(--win95-dark-gray);
}

.profile-actions {
    display: flex;
    gap: 10px;
}

/* =========================
   MODALS
   ========================= */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.active {
    display: flex;
}

.modal-window {
    width: 450px;
    max-width: 90vw;
}

.modal-close {
    cursor: pointer;
}

/* =========================
   STATUS BAR
   ========================= */

.status-bar {
    background-color: var(--win95-gray);
    border-top: 2px groove #ffffff;
    padding: 3px 5px;
    display: flex;
    gap: 10px;
    font-size: 10px;
}

.status-bar-field {
    border-top: 2px solid #808080;
    border-left: 2px solid #808080;
    border-right: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
    padding: 2px 5px;
    background-color: var(--win95-gray);
}

.status-bar-field:first-child {
    flex: 1;
}

/* =========================
   ERROR & SUCCESS MESSAGES
   ========================= */

.error-message,
.success-message {
    padding: 5px;
    margin: 5px 0;
    font-size: 10px;
}

.error-message {
    color: var(--win95-red);
}

.success-message {
    color: var(--win95-green);
}

/* =========================
   PAGINATION
   ========================= */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-top: 15px;
}

.pagination button {
    min-width: 30px;
    padding: 3px 8px;
}

.pagination span {
    padding: 0 10px;
}

/* =========================
   SCROLLBAR (Win95 Style)
   ========================= */

::-webkit-scrollbar {
    width: 16px;
    height: 16px;
}

::-webkit-scrollbar-track {
    background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAEklEQVQIW2P4//+/w39GRgYACYAC/fW3FxAAAAAASUVORK5CYII=');
}

::-webkit-scrollbar-thumb {
    background-color: var(--win95-gray);
    border-top: 2px solid #ffffff;
    border-left: 2px solid #ffffff;
    border-right: 2px solid #808080;
    border-bottom: 2px solid #808080;
}

::-webkit-scrollbar-thumb:hover {
    background-color: #d4d4d4;
}

::-webkit-scrollbar-button {
    background-color: var(--win95-gray);
    border-top: 2px solid #ffffff;
    border-left: 2px solid #ffffff;
    border-right: 2px solid #808080;
    border-bottom: 2px solid #808080;
}

::-webkit-scrollbar-button:vertical:decrement {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M8 4 L4 8 L12 8 Z" fill="black"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
}

::-webkit-scrollbar-button:vertical:increment {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M8 12 L4 8 L12 8 Z" fill="black"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
}

/* =========================
   RESPONSIVE ADJUSTMENTS
   ========================= */

@media (max-width: 768px) {
    .chat-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .users-grid,
    .groups-grid {
        grid-template-columns: 1fr;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
    }

    .app-screen {
        padding: 5px;
    }
}

@media (max-width: 480px) {
    .field-row {
        flex-direction: column;
        align-items: stretch;
    }

    .field-row label {
        width: auto;
        text-align: left;
    }

    menu[role="tablist"] {
        flex-wrap: wrap;
    }

    menu[role="tablist"] button {
        font-size: 10px;
        padding: 3px 8px;
    }
}

/* =========================
   BADGES
   ========================= */

.chat-badge,
.badge {
    display: inline-block;
    padding: 2px 6px;
    margin-left: 5px;
    font-size: 8px;
    font-weight: bold;
    background-color: var(--win95-blue);
    color: var(--win95-white);
    border-top: 1px solid #ffffff;
    border-left: 1px solid #ffffff;
    border-right: 1px solid #000000;
    border-bottom: 1px solid #000000;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-badge.group-badge {
    background-color: var(--win95-green);
}

.badge.pending {
    background-color: #808000;
}

.badge.admin {
    background-color: var(--win95-red);
}

.unread-badge {
    display: inline-block;
    padding: 2px 6px;
    margin-left: 5px;
    font-size: 9px;
    font-weight: bold;
    background-color: #ff0000;
    color: #ffffff;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    border-top: 1px solid #ff6666;
    border-left: 1px solid #ff6666;
    border-right: 1px solid #990000;
    border-bottom: 1px solid #990000;
}

/* =========================
   UTILITIES
   ========================= */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 10px;
}

.mb-1 {
    margin-bottom: 10px;
}

.p-1 {
    padding: 10px;
}
