/* RESET */
*{
    box-sizing:border-box;
}

html, body{
    margin:0;
    min-height:100%;
}

body{
    font-family:Arial, Helvetica, sans-serif;
    min-height:100vh;
    background:linear-gradient(135deg,#74ebd5,#ACB6E5);
    color:#222;
}

/* AUTH */
.container{
    width:min(92vw, 420px);
    background:rgba(255,255,255,0.95);
    padding:34px;
    border-radius:22px;
    box-shadow:0 18px 40px rgba(0,0,0,0.16);
    text-align:center;
}

.auth-card,
.auth-page{
    display:flex;
    justify-content:center;
    align-items:center;
    min-height:100vh;
    padding:20px;
}

.title{
    font-size:2rem;
    margin:0 0 8px;
}

.subtitle{
    font-size:15px;
    color:#6b7280;
    margin-bottom:22px;
}

.auth-form{
    display:flex;
    flex-direction:column;
    gap:2px;
}

.error,
.success{
    padding:12px 14px;
    border-radius:12px;
    font-size:14px;
    margin-bottom:14px;
}

.error{
    background:#ffe7e7;
    color:#c62828;
}

.success{
    background:#e8fff0;
    color:#1f8f4c;
}

input{
    width:100%;
    padding:14px 16px;
    margin:10px 0;
    border-radius:14px;
    border:1px solid #d6d6d6;
    outline:none;
    transition:0.2s ease;
    font-size:15px;
    background:#fff;
}

input:focus{
    border-color:#4facfe;
    box-shadow:0 0 0 4px rgba(79,172,254,0.12);
}

.password-box{
    position:relative;
}

.password-box input{
    padding-right:46px;
}

.password-box span{
    position:absolute;
    right:14px;
    top:50%;
    transform:translateY(-50%);
    cursor:pointer;
    font-size:18px;
}

.password-hint{
    text-align:left;
    font-size:13px;
    color:#6b7280;
    margin-top:4px;
    margin-bottom:10px;
    padding-left:2px;
}

.password-hint.valid{
    color:#1f8f4c;
}

.password-hint.invalid{
    color:#c62828;
}

button,
.primary-btn{
    width:100%;
    padding:13px 16px;
    background:#4CAF50;
    color:white;
    border:none;
    border-radius:14px;
    cursor:pointer;
    font-size:16px;
    font-weight:600;
    transition:0.2s ease;
}

button:hover,
.primary-btn:hover{
    transform:translateY(-1px);
    background:#43a047;
}

.switch-text{
    margin-top:16px;
    font-size:15px;
}

/* CHAT LAYOUT */
.app-shell{
    width:min(95vw, 1500px);
    height:92vh;
    margin:4vh auto;
    display:grid;
    grid-template-columns:300px 1fr;
    gap:20px;
    align-items:stretch;
}

.sidebar{
    background:rgba(255,255,255,0.92);
    border-radius:24px;
    box-shadow:0 18px 40px rgba(0,0,0,0.12);
    padding:18px;
    display:flex;
    flex-direction:column;
    backdrop-filter:blur(10px);
    overflow:hidden;
}

.sidebar-top{
    padding-bottom:14px;
    border-bottom:1px solid #e9e9e9;
    margin-bottom:14px;
}

.brand{
    font-size:24px;
    font-weight:700;
    margin-bottom:8px;
}

.sidebar-subtitle{
    font-size:14px;
    color:#6b7280;
}

.new-chat-btn{
    width:100%;
    margin-bottom:14px;
    background:#2563eb;
    text-align:center;
    text-decoration:none;
    display:block;
}

.new-chat-btn:hover{
    background:#1d4ed8;
}

.history-list{
    display:flex;
    flex-direction:column;
    gap:10px;
    overflow-y:auto;
    padding-right:4px;
}

.history-card{
    display:flex;
    flex-direction:column;
    background:#f8fbff;
    border:1px solid #e5eefb;
    border-radius:16px;
    padding:10px;
}

.history-item-link{
    display:block;
    text-decoration:none;
    padding:14px;
    border-radius:16px;
    background:#f4f8ff;
    color:#1f2937;
    border:1px solid #e7eefb;
    transition:0.2s ease;
}

.history-item-link:hover{
    background:#eaf3ff;
}

.history-item-link.active{
    background:#dbeafe;
    border-color:#93c5fd;
}

.history-title{
    display:block;
    font-weight:600;
    margin-bottom:6px;
    line-height:1.4;
    word-break:break-word;
}

.history-item-link small{
    color:#6b7280;
    font-size:12px;
    word-break:break-word;
}

.delete-chat-btn{
    display:block;
    margin-top:8px;
    text-align:center;
    text-decoration:none;
    background:#ef4444;
    color:white;
    padding:8px 10px;
    border-radius:12px;
    font-size:13px;
    font-weight:600;
    transition:0.2s ease;
}

.delete-chat-btn:hover{
    background:#dc2626;
    transform:translateY(-1px);
}

/* CHAT CONTAINER */
.chat-container{
    width:100%;
    height:100%;
    background:rgba(255,255,255,0.95);
    border-radius:24px;
    display:flex;
    flex-direction:column;
    overflow:hidden;
    box-shadow:0 18px 40px rgba(0,0,0,0.14);
    position:relative;
    min-width:0;
}

.header{
    display:flex;
    justify-content:space-between;
    align-items:center;
    padding:16px 22px;
    background:linear-gradient(135deg,#4facfe,#5aa9f0);
    color:white;
}

.header-title{
    font-size:30px;
    font-weight:700;
}

.header-right{
    display:flex;
    gap:12px;
    align-items:center;
}

.mode-btn{
    width:auto;
    background:#2f2f36;
    color:white;
    padding:10px 14px;
    border-radius:12px;
    border:none;
}

.logout-btn{
    background:#ff2b2b;
    color:white;
    padding:10px 16px;
    border-radius:12px;
    text-decoration:none;
    font-weight:600;
}

.logout-btn:hover{
    background:#e11d1d;
}

/* REMINDER */
.top-reminder{
    display:flex;
    justify-content:flex-end;
    align-items:center;
    gap:12px;
    padding:14px 20px;
    background:#fafafa;
    border-bottom:1px solid #ececec;
}

.top-reminder input{
    width:auto;
    margin:0;
    padding:10px 12px;
}

.top-reminder button{
    width:auto;
    padding:10px 18px;
}

/* CHAT */
.chat-intro{
    text-align:center;
    padding:18px 20px 8px;
}

.welcome{
    margin:0 0 8px;
    font-size:2.1rem;
}

.mood-text{
    margin:0;
    font-size:16px;
    color:#555;
}

.chat-box{
    flex:1;
    padding:24px 28px;
    overflow-y:auto;
    background:linear-gradient(180deg,#f7faff 0%, #eef3f8 100%);
    display:flex;
    flex-direction:column;
    gap:14px;
}

.message-row{
    display:flex;
    width:100%;
}

.message-row.user{
    justify-content:flex-end;
}

.message-row.ai{
    justify-content:flex-start;
}

.bubble{
    padding:15px 18px;
    border-radius:20px;
    max-width:min(75%, 820px);
    line-height:1.6;
    font-size:16px;
    word-wrap:break-word;
    box-shadow:0 10px 20px rgba(0,0,0,0.05);
}

.bubble.user{
    background:#4facfe;
    color:white;
    border-bottom-right-radius:8px;
}

.bubble.ai{
    background:#ffffff;
    color:#222;
    border-bottom-left-radius:8px;
}

.input-area{
    display:flex;
    gap:12px;
    padding:16px 20px 20px;
    background:#fff;
    border-top:1px solid #ececec;
}

.input-area input{
    flex:1;
    border:1px solid #d9e2ec;
    margin:0;
    font-size:15px;
}

.input-area button{
    width:64px;
    border-radius:16px;
    font-size:20px;
    flex-shrink:0;
}

/* DARK MODE */
.dark{
    background:linear-gradient(135deg,#111827,#1f2937);
}

.dark .sidebar,
.dark .chat-container{
    background:rgba(17,24,39,0.92);
    color:#f3f4f6;
}

.dark .sidebar-top{
    border-bottom-color:#2d3748;
}

.dark .sidebar-subtitle,
.dark .history-item-link small,
.dark .mood-text,
.dark .password-hint{
    color:#cbd5e1;
}

.dark .history-card{
    background:#111827;
    border-color:#334155;
}

.dark .history-item-link{
    background:#1f2937;
    color:#f9fafb;
    border-color:#334155;
}

.dark .history-item-link:hover{
    background:#263446;
}

.dark .history-item-link.active{
    background:#1e3a8a;
    border-color:#3b82f6;
}

.dark .delete-chat-btn{
    background:#dc2626;
}

.dark .delete-chat-btn:hover{
    background:#b91c1c;
}

.dark .top-reminder{
    background:#111827;
    border-bottom-color:#273244;
}

.dark .chat-box{
    background:linear-gradient(180deg,#111827 0%, #182230 100%);
}

.dark .bubble.ai{
    background:#243142;
    color:white;
}

.dark .input-area,
.dark .container{
    background:rgba(17,24,39,0.95);
    color:#f3f4f6;
}

.dark input{
    background:#111827;
    color:#f9fafb;
    border-color:#334155;
}

.dark .subtitle,
.dark .switch-text{
    color:#cbd5e1;
}

/* RESPONSIVE */
@media (max-width: 980px){
    .app-shell{
        grid-template-columns:1fr;
        height:auto;
        min-height:92vh;
    }

    .sidebar{
        height:260px;
    }

    .chat-container{
        min-height:70vh;
    }

    .header-title{
        font-size:24px;
    }
}

@media (max-width: 640px){
    .container{
        width:min(94vw, 420px);
        padding:24px;
    }

    .top-reminder{
        flex-wrap:wrap;
        justify-content:center;
    }

    .header{
        padding:14px;
    }

    .header-title{
        font-size:20px;
    }

    .welcome{
        font-size:1.6rem;
    }

    .chat-box{
        padding:16px;
    }

    .bubble{
        max-width:88%;
        font-size:15px;
    }

    .input-area{
        padding:14px;
    }
}

/* TYPING ANIMATION */
.typing-dots{
    display:inline-flex;
    gap:5px;
    align-items:center;
    margin-left:4px;
}

.typing-dots span{
    width:7px;
    height:7px;
    background:#777;
    border-radius:50%;
    display:inline-block;
    animation:typingBounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2){
    animation-delay:0.2s;
}

.typing-dots span:nth-child(3){
    animation-delay:0.4s;
}

@keyframes typingBounce{
    0%, 80%, 100%{
        transform:translateY(0);
        opacity:0.35;
    }

    40%{
        transform:translateY(-6px);
        opacity:1;
    }
}

.dark .typing-dots span{
    background:#cbd5e1;
}