/* =========================================================
   RAVI - Srednja šola Ravne
   ČIST CSS: brez podvojenih pravil
   ========================================================= */

:root {
    --school-red: #b42332;
    --school-red-dark: #791e2a;
    --school-red-light: #fff0f1;
    --page-background: #faf5f5;
    --card-background: #ffffff;
    --chat-background: #fcf9f9;
    --text-primary: #1f2933;
    --text-secondary: #667482;
    --border-color: #eadcdf;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    height: 100dvh;
    color: var(--text-primary);
    background:
        radial-gradient(circle at top center, rgba(180, 35, 50, 0.08), transparent 420px),
        var(--page-background);
}

.app-wrapper {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

main.container {
    width: 100%;
    max-width: 1328px;
    min-height: 0;
    flex: 1;
    display: flex;
    padding: 14px 24px !important;
}

/* =========================================================
   GLAVNA KARTICA
   ========================================================= */

.chat-card {
    width: 100%;
    max-width: 900px;
    height: 100%;
    min-height: 0;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    box-shadow: 0 18px 50px rgba(31, 41, 51, 0.10);
}

.chat-card.chat-started {
    max-width: 1280px;
}

/* =========================================================
   TOOLBAR
   ========================================================= */

.chat-toolbar {
    min-height: 76px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
}

.chat-toolbar-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-toolbar-logo {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    object-fit: contain;
    cursor: pointer;
    filter: drop-shadow(0 3px 8px rgba(180, 35, 50, 0.16));
}

.chat-toolbar-name {
    color: var(--school-red-dark);
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1.1;
}

.chat-toolbar-subtitle {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.2;
}

.chat-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-toolbar-school-logo {
    display: block;
    width: auto;
    height: 52px;
    max-width: 180px;
    object-fit: contain;
}

.chat-card:not(.chat-started) #newChatButton {
    display: none;
}

.chat-card.chat-started .chat-toolbar-school-logo {
    display: none;
}

.chat-card.chat-started #newChatButton {
    display: inline-flex;
}

.privacy-info-button {
    width: 42px;
    height: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 10px;
    font-size: 1.05rem;
    line-height: 1;
}

.new-chat-button {
    width: 42px;
    height: 42px;
    padding: 0;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 10px;
    font-size: 1.1rem;
    line-height: 1;
}

/* =========================================================
   ZAČETNI ZASLON
   ========================================================= */

.ravi-intro {
    display: grid;
    grid-template-columns: minmax(330px, 0.9fr) minmax(360px, 1.1fr);
    align-items: center;
    gap: 42px;
    width: 100%;
    min-height: 0;
    flex: 1;
    padding: 30px 48px 32px;
    text-align: left;
    background:
        radial-gradient(circle at 75% 20%, rgba(180, 35, 50, 0.13), transparent 330px),
        linear-gradient(180deg, #ffffff, #fff7f8);
    border-bottom: 1px solid var(--border-color);
}

.chat-card.chat-started .ravi-intro {
    display: none;
}

.ravi-intro-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.message-label {
    display: inline-flex;
    align-items: center;
    margin: 0 0 20px;
    padding: 5px 14px;
    color: #b42332;
    background: #fff3f4;
    border: 1px solid #f0d5d9;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    white-space: nowrap;
}

.message-label strong {
    color: var(--school-red-dark);
    font-weight: 900;
}

.ravi-welcome-title {
    margin: 0 0 4px;
    color: var(--school-red-dark);
    font-size: 1.55rem;
    font-weight: 750;
    text-align: left;
}

.ravi-welcome-title span {
    color: #b42332;
    font-weight: 800;
}

.ravi-welcome-text {
    margin: 0 0 24px;
    color: #66545a;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
    text-align: left;
}

.quick-actions {
    width: 100%;
    max-width: 380px;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 12px;
}

.quick-action-button {
    width: 100%;
    min-width: 0;
    min-height: 110px;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    background: #fff;
    border: 1px solid #eadcdf;
    border-radius: 16px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.quick-action-button:hover {
    transform: translateY(-3px);
    border-color: rgba(180, 35, 50, 0.25);
    box-shadow: 0 10px 22px rgba(180, 35, 50, 0.12);
}

.quick-action-icon {
    color: var(--school-red);
    font-size: 2rem;
    line-height: 1;
}

.quick-action-title {
    color: var(--school-red-dark);
    font-size: 1rem;
    font-weight: 700;
}

.quick-action-subtitle {
    color: #667085;
    font-size: 0.8rem;
    line-height: 1.25;
    text-align: center;
}

/* =========================================================
   AVATAR - ENA OSNOVNA DEFINICIJA
   ========================================================= */

.ravi-avatar-wrapper {
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    aspect-ratio: var(--ravi-frame-ratio, 9 / 10);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 12px 30px rgba(180, 35, 50, 0.22);
    transition: box-shadow 350ms ease-out, transform 180ms ease;
}

.ravi-avatar-wrapper::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
    border-radius: inherit;
    box-shadow: inset 0 0 0 6px var(--school-red);
}

.ravi-avatar-wrapper::after {
    content: "";
    position: absolute;
    inset: 6px;
    z-index: 21;
    pointer-events: none;
    border-radius: 14px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.ravi-avatar-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 180ms ease;
}

.ravi-avatar-video.is-active {
    opacity: 1;
    visibility: visible;
}

/* Začetni RAVI: velikost se spreminja samo tukaj. */
.ravi-intro-avatar {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ravi-intro-avatar .ravi-avatar-wrapper {
    width: auto;
    max-width: 100%;
    height: min(420px, calc(100dvh - 245px));
    max-height: 100%;
    aspect-ratio: var(--ravi-frame-ratio, 9 / 10);
    margin: 0 auto;
}

.ravi-intro-avatar .ravi-avatar-video {
    object-fit: cover;
}

/* =========================================================
   STANJA AVATARJA
   ========================================================= */

.ravi-avatar-wrapper[data-state="idle"] {
    box-shadow:
        0 0 18px rgba(180, 35, 50, 0.18),
        0 12px 30px rgba(180, 35, 50, 0.22);
}

.ravi-avatar-wrapper[data-state="idle"]::before {
    box-shadow:
        inset 0 0 0 6px var(--school-red),
        inset 0 0 12px rgba(180, 35, 50, 0.15);
}

.ravi-avatar-wrapper[data-state="thinking"] {
    animation: ravi-thinking-wrapper 2s ease-in-out infinite;
}

.ravi-avatar-wrapper[data-state="thinking"]::before {
    animation: ravi-thinking-border 2s ease-in-out infinite;
}

.ravi-avatar-wrapper[data-state="talking"] {
    animation: ravi-talking-wrapper 1.1s ease-in-out infinite;
}

.ravi-avatar-wrapper[data-state="talking"]::before {
    animation: ravi-talking-border 1.1s ease-in-out infinite;
}

@keyframes ravi-talking-wrapper {
    0%, 100% {
        box-shadow:
            0 0 20px rgba(172, 28, 47, 0.25),
            0 12px 30px rgba(180, 35, 50, 0.22);
    }
    45% {
        box-shadow:
            0 0 42px rgba(172, 28, 47, 1),
            0 12px 30px rgba(180, 35, 50, 0.22);
    }
}

@keyframes ravi-talking-border {
    0%, 100% {
        box-shadow:
            inset 0 0 0 6px var(--school-red),
            inset 0 0 0 rgba(172, 28, 47, 0);
    }
    45% {
        box-shadow:
            inset 0 0 0 6px var(--school-red),
            inset 0 0 28px rgba(172, 28, 47, 0.9);
    }
}

@keyframes ravi-thinking-wrapper {
    0%, 100% {
        box-shadow:
            0 0 18px rgba(113, 27, 40, 0.20),
            0 12px 30px rgba(180, 35, 50, 0.22);
    }
    50% {
        box-shadow:
            0 0 38px rgba(113, 27, 40, 1),
            0 12px 30px rgba(180, 35, 50, 0.22);
    }
}

@keyframes ravi-thinking-border {
    0%, 100% {
        box-shadow:
            inset 0 0 0 6px var(--school-red),
            inset 0 0 0 rgba(113, 27, 40, 0);
    }
    50% {
        box-shadow:
            inset 0 0 0 6px var(--school-red),
            inset 0 0 28px rgba(113, 27, 40, 0.75);
    }
}

/* =========================================================
   POGOVOR
   ========================================================= */

.chat-layout {
    display: none;
    min-height: 0;
    flex: 1;
    overflow: hidden;
}

.chat-card.chat-started .chat-layout {
    display: flex;
}

.chat-sidebar {
    width: 380px;
    flex: 0 0 380px;
    min-height: 0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #fdf7f8;
    border-right: 1px solid var(--border-color);
}

.chat-sidebar .ravi-avatar-wrapper {
    height: auto;
    max-height: 440px;
    width: 100%;
    max-width: 100%;
    aspect-ratio: var(--ravi-frame-ratio, 9 / 10);
    margin: 0 auto 14px;
}

.sidebar-subtitle {
    margin: 0;
    color: #6b7280;
    font-size: 0.82rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.sidebar-subtitle strong {
    color: #b42332;
    font-weight: 800;
}

.chat-area {
    min-width: 0;
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 28px;
    overflow-y: auto;
    background: var(--chat-background);
}

.chat-area:empty {
    display: none;
}

.chat-message {
    width: fit-content;
    max-width: 80%;
    padding: 13px 17px;
    border-radius: 18px;
    box-shadow: 0 3px 12px rgba(31, 41, 51, 0.06);
}

.user-message {
    align-self: flex-end;
    color: #fff;
    background: var(--school-red);
    border-bottom-right-radius: 5px;
}

.assistant-message {
    align-self: flex-start;
    color: var(--text-primary);
    background: #fff;
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 5px;
}

.message-author {
    display: block;
    margin-bottom: 5px;
    font-size: 0.76rem;
    font-weight: 800;
    opacity: 0.72;
}

.message-text {
    margin: 0;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.message-text > *:last-child {
    margin-bottom: 0;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.typing-avatar {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    object-fit: contain;
}

/* Stari mobilni header ni več potreben, ker toolbar ostane viden. */
.chat-mobile-header {
    display: none;
}

/* =========================================================
   VNOS
   ========================================================= */

.question-area {
    flex-shrink: 0;
    padding: 18px 28px;
    background: #fff;
    border-top: 1px solid var(--border-color);
}

.question-area .form-control {
    min-height: 48px;
    max-height: 180px;
    resize: none;
    overflow-y: hidden;
    border-color: var(--border-color);
    border-radius: 14px 0 0 14px;
}

.question-area .form-control:focus {
    border-color: rgba(180, 35, 50, 0.55);
    box-shadow: 0 0 0 0.2rem rgba(180, 35, 50, 0.12);
}

.question-area .btn {
    border-radius: 0 14px 14px 0;
}

.send-button {
    width: 52px;
    min-width: 52px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.send-button i {
    transition: transform 0.2s ease;
}

.send-button:hover i {
    transform: translateX(2px);
}

.btn-primary {
    background: var(--school-red);
    border-color: var(--school-red);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--school-red-dark);
    border-color: var(--school-red-dark);
}

.btn-primary:disabled {
    background: var(--school-red);
    border-color: var(--school-red);
    opacity: 0.6;
}

/* =========================================================
   TABLET / SREDNJE ŠIRINE
   ========================================================= */

@media (min-width: 769px) and (max-width: 1100px) {
    main.container {
        padding: 12px;
    }

    .ravi-intro {
        grid-template-columns: minmax(300px, 0.95fr) minmax(300px, 1.05fr);
        gap: 28px;
        padding: 22px 32px 24px;
    }

    .ravi-intro-avatar .ravi-avatar-wrapper {
        height: min(400px, calc(100dvh - 230px));
    }

    .chat-sidebar {
        width: 320px;
        flex-basis: 320px;
        padding: 18px;
    }

    .chat-area {
        padding: 22px;
    }

    .question-area {
        padding: 16px 20px 20px;
    }
}

/* =========================================================
   TELEFON
   ========================================================= */

@media (max-width: 768px) {

    html,
    body {
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    body {
        background: var(--page-background);
    }

    main.container {
        position: fixed;
        inset: 0;

        width: 100%;
        max-width: 100%;
        height: 100dvh;

        padding: 8px !important;
        margin: 0;

        overflow: hidden;
    }

    .chat-card,
    .chat-card.chat-started {
        width: 100%;
        max-width: 100%;
        height: 100%;

        border-radius: 18px;
    }


    /* =====================================================
       TOOLBAR
       ===================================================== */

    .chat-toolbar {
        min-height: 60px;
        flex-shrink: 0;

        gap: 10px;
        padding: 8px 12px;
    }

    .chat-toolbar-logo {
        width: 36px;
        height: 36px;
    }

    .chat-toolbar-name {
        font-size: 0.95rem;
    }

    .chat-toolbar-subtitle {
        max-width: 190px;

        font-size: 0.68rem;

        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .chat-toolbar-school-logo {
        height: 38px;
        max-width: 115px;
    }

    #newChatButton {
        width: 38px;
        height: 38px;
        padding: 0;
        font-size: 1rem;
        white-space: nowrap;
    }


    /* =====================================================
       ZAČETNI ZASLON
       ===================================================== */

    .ravi-intro {
        flex: 1;
        min-height: 0;

        display: flex;
        flex-direction: column;
        align-items: center;

        gap: 10px;
        padding: 10px 14px;

        overflow: hidden;

        text-align: center;
    }

    .ravi-intro-content {
        display: contents;
    }

    .message-label {
        order: 1;

        flex-shrink: 0;

        margin: 4px 0 2px;
        padding: 5px 12px;

        font-size: 0.78rem;
        font-weight: 700;
        letter-spacing: 0.07em;

        white-space: nowrap;
    }

    .ravi-intro-avatar {
        order: 2;

        flex: 1;
        min-height: 0;
        width: 100%;
        padding: 14px 0 18px;

        display: flex;
        align-items: center;
        justify-content: center;
    }

    .ravi-intro-avatar .ravi-avatar-wrapper {
        width: 68vw;
        max-width: 320px;
        height: auto;
        max-height: 100%;

        aspect-ratio: var(--ravi-frame-ratio, 9 / 10);

        margin: 0 auto;
    }

    .ravi-intro-avatar .ravi-avatar-video {
        object-fit: cover;
    }

    /*
       Na telefonu pozdrava ne potrebujemo.
       Tako dobi RAVI dovolj prostora in nič ne gre pod input.
    */
    .ravi-welcome-title,
    .ravi-welcome-text,
    .quick-actions {
        display: none;
    }


    /* =====================================================
       POGOVOR
       ===================================================== */

    .chat-sidebar {
        display: none;
    }

    .chat-card.chat-started .chat-layout {
        display: flex;

        flex: 1;
        min-height: 0;

        width: 100%;

        overflow: hidden;
    }

    .chat-area {
        width: 100%;

        min-height: 0;

        padding: 16px 14px;

        overflow-y: auto;
        overscroll-behavior: contain;

        -webkit-overflow-scrolling: touch;
    }

    .chat-message {
        max-width: 90%;
    }


    /* =====================================================
       VNOS
       ===================================================== */

    .question-area {
        flex-shrink: 0;

        padding: 10px 12px;

        background: #fff;
    }

    .question-area .form-control {
        min-height: 44px;

        font-size: 16px;
    }

    .send-button {
        width: 48px;
        min-width: 48px;
    }
}

/* =========================================================
   NIZKI ZASLONI
   ========================================================= */

@media (min-width: 769px) and (max-height: 800px) {
    .ravi-intro {
        padding-top: 22px;
        padding-bottom: 24px;
    }

    .ravi-intro-avatar .ravi-avatar-wrapper {
        width: auto;
        height: min(380px, calc(100dvh - 220px));
        aspect-ratio: var(--ravi-frame-ratio, 9 / 10);
    }

    .quick-action-button {
        min-height: 88px;
    }

    .ravi-welcome-text {
        margin-bottom: 16px;
    }

    .message-label {
        margin-bottom: 12px;
    }
}

/* =========================================================
   FOOTER
   ========================================================= */

.app-footer {
    display: none;
}

@media (min-width: 769px) {
    .app-footer {
        margin-top: auto;
        padding: 4px 20px 10px;
        display: block;

        color: #8a949f;
        font-size: 0.72rem;
        font-weight: 400;
        text-align: center;
    }
}
