/**
 * J Chat - Ana Stil Dosyası
 * Discord benzeri dark theme
 */

/* ===== CSS VARIABLES ===== */
:root {
    /* Tema Renkleri - Varsayılan: Blue */
    --primary: #5865F2;
    --primary-hover: #4752c4;

    /* Arka Plan Renkleri */
    --bg-dark: #202225;
    --bg-secondary: #2f3136;
    --bg-tertiary: #36393f;
    --bg-input: #40444b;
    --bg-hover: #34373c;
    --bg-active: #3f4248;

    /* Metin Renkleri */
    --text-normal: #dcddde;
    --text-muted: #72767d;
    --text-link: #00aff4;
    --header-primary: #ffffff;
    --header-secondary: #b9bbbe;

    /* Durum Renkleri */
    --success: #3ba55c;
    --danger: #ed4245;
    --warning: #faa61a;
    --info: #5865F2;

    /* Çevrimiçi Durumları */
    --status-online: #3ba55c;
    --status-idle: #faa61a;
    --status-dnd: #ed4245;
    --status-offline: #747f8d;

    /* Boyutlar */
    --sidebar-width: 72px;
    --channels-width: 240px;
    --members-width: 240px;
    --header-height: 48px;
    --input-height: 68px;

    /* Border */
    --border-color: #202225;
    --border-radius: 8px;
    --border-radius-sm: 4px;

    /* Shadows */
    --shadow-low: 0 1px 0 rgba(4, 4, 5, 0.2);
    --shadow-medium: 0 4px 8px rgba(0, 0, 0, 0.24);
    --shadow-high: 0 8px 16px rgba(0, 0, 0, 0.24);

    /* Transitions */
    --transition-fast: 0.1s ease;
    --transition-normal: 0.2s ease;
}

/* ===== THEME VARIANTS ===== */
.theme-blue {
    --primary: #5865F2;
    --primary-hover: #4752c4;
}

.theme-red {
    --primary: #ed4245;
    --primary-hover: #c73e40;
}

.theme-orange {
    --primary: #f57731;
    --primary-hover: #d4662a;
}

.theme-purple {
    --primary: #9b84ec;
    --primary-hover: #8470d1;
}

.theme-yellow {
    --primary: #faa61a;
    --primary-hover: #d99316;
}

/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Segoe UI', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-normal);
    background-color: var(--bg-dark);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--text-link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
}

input,
textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: var(--bg-input);
    border: none;
    outline: none;
}

input:focus,
textarea:focus {
    outline: none;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background-color: #2e3338;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background-color: #202225;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: #18191c;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #202225 #2e3338;
}

/* ===== LAYOUT - DISCORD GRID ===== */
:root:not(.auth-page),
body:not(.auth-page) {
    margin: 0;
    padding: 0;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
}

/* html elementini kitleme ama body'yi kitle (auth hariç) */
html:not(.auth-page) {
    overflow: hidden;
    height: 100dvh;
}

body:not(.auth-page) {
    position: fixed;
}

.app-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) var(--channels-width) 1fr var(--members-width);
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    background-color: var(--bg-dark);
}

/* Auth sayfalarında scroll izni */
body.auth-page {
    overflow: auto;
    height: auto;
    min-height: 100vh;
}

body.auth-page .auth-container {
    min-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Responsive */
@media (max-width: 992px) {
    .app-container {
        grid-template-columns: var(--sidebar-width) var(--channels-width) 1fr;
    }

    .members-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
        position: relative;
    }

    .servers-sidebar,
    .channels-sidebar {
        display: none;
    }

    /* Mobil menü butonu */
    .mobile-menu-btn {
        display: flex;
        position: fixed;
        bottom: 20px;
        left: 20px;
        z-index: 1000;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--primary);
        color: white;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        box-shadow: var(--shadow-high);
        border: none;
        cursor: pointer;
        transition: transform 0.2s, background 0.2s;
    }

    .mobile-menu-btn:hover {
        transform: scale(1.1);
    }

    .mobile-menu-btn.active {
        background: var(--danger);
    }

    /* Mobil sidebar overlay */
    .mobile-sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.7);
        z-index: 999;
    }

    .mobile-sidebar-overlay.active {
        display: block;
    }

    /* Mobil sidebar */
    .mobile-sidebar {
        display: none;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 300px;
        background: var(--bg-secondary);
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        flex-direction: column;
        overflow-y: auto;
    }

    .mobile-sidebar.active {
        display: flex;
        transform: translateX(0);
    }

    /* Collapsible section header */
    .collapsible-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        background: var(--bg-tertiary);
        cursor: pointer;
        user-select: none;
        transition: background 0.2s;
    }

    .collapsible-header:hover {
        background: var(--bg-hover);
    }

    .collapsible-header .toggle-icon {
        transition: transform 0.2s;
    }

    .collapsible-header.collapsed .toggle-icon {
        transform: rotate(-90deg);
    }

    .collapsible-content {
        max-height: 500px;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .collapsible-content.collapsed {
        max-height: 0;
    }
}

@media (min-width: 769px) {

    .mobile-menu-btn,
    .mobile-sidebar-overlay,
    .mobile-sidebar {
        display: none !important;
    }
}

/* ===== SERVERS SIDEBAR (Sol En Dış) ===== */
.servers-sidebar {
    background-color: var(--bg-dark);
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
}

.server-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-normal);
    font-weight: 600;
    font-size: 18px;
    cursor: pointer;
    transition: border-radius var(--transition-normal), background-color var(--transition-normal);
    position: relative;
}

.server-icon:hover {
    border-radius: 16px;
    background-color: var(--primary);
    color: white;
}

.server-icon.active {
    border-radius: 16px;
    background-color: var(--primary);
    color: white;
}

.server-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.server-indicator {
    position: absolute;
    left: -4px;
    width: 4px;
    height: 8px;
    background-color: var(--header-primary);
    border-radius: 0 4px 4px 0;
    transition: height var(--transition-normal);
}

.server-icon:hover .server-indicator,
.server-icon.active .server-indicator {
    height: 20px;
}

.server-divider {
    width: 32px;
    height: 2px;
    background-color: var(--bg-tertiary);
    border-radius: 1px;
    margin: 4px 0;
}

.server-add {
    background-color: var(--bg-tertiary);
    color: var(--success);
}

.server-add:hover {
    background-color: var(--success);
    color: white;
}

/* ===== CHANNELS SIDEBAR ===== */
.channels-sidebar {
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: relative;
    border-right: 1px solid var(--border-color);
}

.channel-header {
    height: var(--header-height);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    color: var(--header-primary);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color var(--transition-fast);
    box-shadow: var(--shadow-low);
}

.channel-header:hover {
    background-color: var(--bg-hover);
}

.channel-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    /* User panel için boşluk bırak */
    padding-bottom: 60px;
}

.channel-category {
    padding: 16px 8px 4px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.channel-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-radius: var(--border-radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    gap: 8px;
}

.channel-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-normal);
}

.channel-item.active {
    background-color: var(--bg-active);
    color: var(--header-primary);
}

.channel-item i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

/* ===== USER PANEL (Alt - Sabit) ===== */
.user-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 52px;
    background-color: var(--bg-secondary);
    display: flex;
    align-items: center;
    padding: 8px;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    z-index: 100;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    position: relative;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 3px solid var(--bg-secondary);
}

.status-online {
    background-color: var(--status-online);
}

.status-idle {
    background-color: var(--status-idle);
}

.status-dnd {
    background-color: var(--status-dnd);
}

.status-offline {
    background-color: var(--status-offline);
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--header-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Çevrimiçi Yazı Stili */
.status-online-text {
    color: var(--status-online) !important;
    text-shadow: 0 0 8px rgba(59, 165, 92, 0.2);
    font-weight: 600 !important;
}

.user-tag {
    font-size: 12px;
    color: var(--text-muted);
}

.user-controls {
    display: flex;
    gap: 4px;
}

.user-controls button {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.user-controls button:hover {
    background-color: var(--bg-hover);
    color: var(--text-normal);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    background-color: var(--bg-tertiary);
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.main-header {
    height: var(--header-height);
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-low);
}

.main-header-icon {
    color: var(--text-muted);
    font-size: 20px;
}

.main-header-title {
    font-weight: 600;
    color: var(--header-primary);
}

.main-header-divider {
    width: 1px;
    height: 24px;
    background-color: var(--text-muted);
    opacity: 0.3;
}

.main-header-topic {
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== CHAT AREA ===== */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background-color: var(--bg-tertiary);
    height: calc(100dvh - var(--header-height));
    min-height: 0;
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 0;
}

/* Empty State */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    color: var(--header-primary);
    margin-bottom: 8px;
}

.message {
    display: flex;
    gap: 16px;
    padding: 4px 0;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
}

.message:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
    margin-top: 2px;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.message-author {
    font-weight: 600;
    color: var(--header-primary);
    cursor: pointer;
}

.message-author:hover {
    text-decoration: underline;
}

.message-timestamp {
    font-size: 12px;
    color: var(--text-muted);
}

.message-text {
    color: var(--text-normal);
    word-wrap: break-word;
}

.message-edited {
    font-size: 10px;
    color: var(--text-muted);
}

/* ===== MESSAGE INPUT ===== */
.message-input-container {
    padding: 0 16px 24px;
    background-color: var(--bg-tertiary);
    flex-shrink: 0;
    /* Küçülmesini engelle */
}

.message-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--bg-input);
    border-radius: var(--border-radius);
    padding: 12px 16px;
}

.message-input-wrapper button {
    background: transparent;
    color: var(--text-muted);
    font-size: 20px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.message-input-wrapper button:hover {
    color: var(--text-normal);
}

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-normal);
    font-size: 16px;
    resize: none;
    max-height: 200px;
}

.message-input::placeholder {
    color: var(--text-muted);
}

/* ===== MEMBERS SIDEBAR ===== */
.members-sidebar {
    background-color: var(--bg-secondary);
    padding: 16px 8px;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
}

.members-category {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px 8px 4px;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.member-item:hover {
    background-color: var(--bg-hover);
}

.member-avatar {
    position: relative;
}

.member-name {
    color: var(--text-muted);
    font-weight: 500;
}

.member-item:hover .member-name {
    color: var(--text-normal);
}

.member-status-text {
    font-size: 12px;
    color: var(--text-muted);
}