/* ===========================================
   Messages - iOS-Inspired Clean Design
   Smooth, tečno, bez distrakcija
   =========================================== */

/* CSS Variables for consistency */
:root {
    --msg-primary: #564233;
    --msg-accent: #d4a373;
    --msg-bg: #fdf8f0;
    --msg-surface: #ffffff;
    --msg-border: #e6e1d8;
    --msg-text: #564233;
    --msg-text-light: #8c7b70;
    --msg-sent-bg: #564233;
    --msg-received-bg: rgba(230, 225, 216, 0.6);
    --msg-radius: 18px;
    --msg-radius-sm: 12px;
    --msg-transition: 0.2s ease;
}

/* ===========================================
   Main Container
   =========================================== */

.krpice-messages {
    max-width: 800px;
    margin: 0 auto;
}

/* ===========================================
   Conversations List View - iOS Style
   =========================================== */

.conversations-list-view {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.messages-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--msg-border);
}

.messages-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0;
    color: var(--msg-text);
    letter-spacing: -0.02em;
}

/* Conversations List */
.conversations-list {
    display: flex;
    flex-direction: column;
    background: var(--msg-surface);
    border-radius: var(--msg-radius-sm);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(86, 66, 51, 0.08);
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    text-decoration: none;
    color: var(--msg-text);
    background: var(--msg-surface);
    border-bottom: 1px solid rgba(230, 225, 216, 0.5);
    transition: background var(--msg-transition), transform 0.15s ease;
    position: relative;
}

.conversation-item:last-child {
    border-bottom: none;
}

.conversation-item:hover {
    background: var(--msg-bg);
}

.conversation-item:active {
    transform: scale(0.98);
    background: rgba(230, 225, 216, 0.4);
}

.conversation-item.unread {
    background: linear-gradient(135deg, rgba(212, 163, 115, 0.08) 0%, var(--msg-surface) 100%);
}

.conversation-item.unread .conv-name {
    font-weight: 700;
}

.conversation-item.unread .conv-preview {
    color: var(--msg-text);
    font-weight: 500;
}

/* Avatar with Ad Image - iOS Style */
.conv-avatar {
    position: relative;
    flex-shrink: 0;
}

.conv-avatar img {
    width: 56px;
    height: 56px;
    border-radius: var(--msg-radius-sm);
    object-fit: cover;
}

/* Content */
.conv-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.conv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conv-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--msg-text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.conv-time {
    font-size: 0.8125rem;
    color: var(--msg-text-light);
}

.conv-subject {
    font-size: 0.8125rem;
    color: var(--msg-accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-preview {
    font-size: 0.875rem;
    color: var(--msg-text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    gap: 4px;
}

.you-label {
    color: var(--msg-text-light);
    flex-shrink: 0;
}

/* Unread Badge */
.conv-badge {
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    background: var(--msg-accent);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Chevron for non-unread items */
.conversation-item:not(.unread)::after {
    content: '';
    width: 7px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='12' fill='none'%3E%3Cpath d='M1 1l5 5-5 5' stroke='%238c7b70' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' opacity='0.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    flex-shrink: 0;
    opacity: 0.5;
}

/* ===========================================
   Single Conversation View - Chat Style
   =========================================== */

.conversation-view {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 220px);
    min-height: 500px;
    max-height: 750px;
    background: var(--msg-surface);
    border-radius: var(--msg-radius-sm);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(86, 66, 51, 0.08);
    animation: fadeIn 0.3s ease;
}

/* Chat Header - iOS Style */
.conversation-header {
    padding: 12px 16px;
    background: var(--msg-surface);
    border-bottom: 1px solid var(--msg-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--msg-text);
    text-decoration: none;
    padding: 4px 0;
    transition: opacity var(--msg-transition);
}

.back-link::before {
    content: '';
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none'%3E%3Cpath d='M12.5 15l-5-5 5-5' stroke='%23564233' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    transition: transform var(--msg-transition);
}

.back-link:hover {
    opacity: 0.7;
}

.back-link:hover::before {
    transform: translateX(-2px);
}

.conversation-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.conversation-title {
    flex: 1;
    min-width: 0;
}

.conversation-title h1 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0 0 2px;
    color: var(--msg-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-title h1 a {
    color: inherit;
    text-decoration: none;
}

.conversation-title h1 a:hover {
    color: var(--msg-accent);
}

.conversation-with {
    font-size: 0.8125rem;
    color: var(--msg-text-light);
}

.conversation-with a {
    color: inherit;
    text-decoration: none;
}

.conversation-with a:hover {
    color: var(--msg-accent);
}

.conversation-with strong {
    color: var(--msg-text);
    font-weight: 500;
}

/* Rate Button */
.btn-rate {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    color: var(--msg-text);
    border: 1.5px solid var(--msg-border);
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--msg-transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-rate:hover {
    background: var(--msg-primary);
    border-color: var(--msg-primary);
    color: #fff;
}

.btn-rate i {
    font-size: 0.875rem;
}

/* ===========================================
   Messages Container - Chat Bubbles
   =========================================== */

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--msg-bg);
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Thin scrollbar */
.messages-container::-webkit-scrollbar {
    width: 4px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(86, 66, 51, 0.15);
    border-radius: 2px;
}

/* Date Separator */
.date-separator {
    text-align: center;
    margin: 12px 0;
}

.date-separator span {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(140, 123, 112, 0.1);
    border-radius: 10px;
    font-size: 0.75rem;
    color: var(--msg-text-light);
    font-weight: 500;
}

/* Message Bubbles - iOS Style */
.message {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    animation: messageAppear 0.2s ease;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message.sent {
    align-self: flex-end;
}

.message.received {
    align-self: flex-start;
}

.message-content {
    padding: 10px 14px;
    border-radius: var(--msg-radius);
    font-size: 0.9375rem;
    line-height: 1.45;
    word-wrap: break-word;
}

.message.sent .message-content {
    background: var(--msg-sent-bg);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.received .message-content {
    background: var(--msg-received-bg);
    color: var(--msg-text);
    border-bottom-left-radius: 4px;
}

.message-meta {
    font-size: 0.6875rem;
    color: var(--msg-text-light);
    margin-top: 4px;
    padding: 0 4px;
}

.message.sent .message-meta {
    text-align: right;
}

/* ===========================================
   Message Input - iOS Style
   =========================================== */

.message-form {
    padding: 12px 16px;
    background: var(--msg-surface);
    border-top: 1px solid var(--msg-border);
}

.form-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message-form textarea {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 20px;
    font-size: 0.9375rem;
    font-family: inherit;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    line-height: 1.4;
    background: rgba(230, 225, 216, 0.5);
    color: var(--msg-text);
    transition: background var(--msg-transition), box-shadow var(--msg-transition);
}

.message-form textarea::placeholder {
    color: var(--msg-text-light);
}

.message-form textarea:focus {
    outline: none;
    background: rgba(230, 225, 216, 0.7);
    box-shadow: 0 0 0 2px rgba(212, 163, 115, 0.2);
}

/* Send Button - iOS Style */
.btn-send {
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--msg-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--msg-transition);
    flex-shrink: 0;
}

.btn-send:hover {
    background: #3d2e24;
    transform: scale(1.05);
}

.btn-send:active {
    transform: scale(0.95);
}

.btn-send:disabled {
    background: var(--msg-text-light);
    cursor: not-allowed;
    transform: none;
}

.btn-send svg {
    width: 18px;
    height: 18px;
}

/* Sending state animation */
.btn-send.sending {
    pointer-events: none;
}

.btn-send.sending svg {
    animation: sendPulse 0.6s ease infinite;
}

@keyframes sendPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.9); }
}

/* ===========================================
   Toast Notification - Replaces Alerts
   =========================================== */

.krpice-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--msg-text);
    color: #fff;
    padding: 12px 20px;
    border-radius: 24px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.krpice-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.krpice-toast.error {
    background: #c0392b;
}

.krpice-toast.success {
    background: #27ae60;
}

/* ===========================================
   Empty State - iOS Style
   =========================================== */

.empty-state {
    text-align: center;
    padding: 60px 24px;
    background: var(--msg-surface);
    border-radius: var(--msg-radius-sm);
    animation: fadeIn 0.4s ease;
}

.empty-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 24px;
    background: var(--msg-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}

.empty-state h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--msg-text);
}

.empty-state p {
    font-size: 0.9375rem;
    color: var(--msg-text-light);
    margin: 0 0 24px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

.btn-browse {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--msg-primary);
    color: #fff;
    border-radius: 24px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all var(--msg-transition);
}

.btn-browse:hover {
    background: #3d2e24;
    color: #fff;
    transform: translateY(-1px);
}

.btn-browse::after {
    content: '→';
    font-size: 1rem;
    transition: transform var(--msg-transition);
}

.btn-browse:hover::after {
    transform: translateX(4px);
}

/* ===========================================
   Review Modal - Clean iOS Style
   =========================================== */

.review-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(86, 66, 51, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.review-modal.active {
    display: flex;
    opacity: 1;
}

.review-modal-content {
    background: var(--msg-surface);
    padding: 28px;
    border-radius: var(--msg-radius);
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 20px 60px rgba(86, 66, 51, 0.25);
    animation: modalSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    background: var(--msg-bg);
    border: none;
    font-size: 18px;
    color: var(--msg-text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--msg-transition);
}

.modal-close:hover {
    background: var(--msg-border);
    color: var(--msg-text);
}

.review-modal-content h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--msg-text);
}

.modal-subtitle {
    font-size: 0.875rem;
    color: var(--msg-text-light);
    margin: 0 0 24px;
}

.rating-field,
.comment-field {
    margin-bottom: 20px;
}

.rating-field label,
.comment-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--msg-text);
    margin-bottom: 8px;
}

/* Rating Options - Elegant Style */
.rating-options {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.rating-options input {
    display: none;
}

.rating-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    flex: 1;
    max-width: 140px;
}

.rating-option .rating-symbol {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 600;
    line-height: 1;
    color: var(--color-text-light);
    transition: color 0.2s ease;
}

.rating-option .rating-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-light);
    transition: color 0.2s ease;
}

.rating-option:hover {
    border-color: var(--color-accent);
}

/* Positive Option Styles */
.rating-option-positive:hover,
#rating-positive:checked + .rating-option-positive {
    border-color: var(--color-success);
    background: var(--color-surface);
}

.rating-option-positive:hover .rating-symbol,
#rating-positive:checked + .rating-option-positive .rating-symbol {
    color: var(--color-success);
}

#rating-positive:checked + .rating-option-positive .rating-label {
    color: var(--color-text);
}

/* Negative Option Styles */
.rating-option-negative:hover,
#rating-negative:checked + .rating-option-negative {
    border-color: var(--color-text-light);
    background: var(--color-surface);
}

.rating-option-negative:hover .rating-symbol,
#rating-negative:checked + .rating-option-negative .rating-symbol {
    color: var(--color-text);
}

#rating-negative:checked + .rating-option-negative .rating-label {
    color: var(--color-text);
}

.comment-field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--msg-border);
    border-radius: var(--msg-radius-sm);
    font-size: 0.9375rem;
    font-family: inherit;
    resize: vertical;
    min-height: 90px;
    transition: all var(--msg-transition);
    background: var(--msg-surface);
}

.comment-field textarea::placeholder {
    color: var(--msg-text-light);
}

.comment-field textarea:focus {
    outline: none;
    border-color: var(--msg-accent);
    box-shadow: 0 0 0 3px rgba(212, 163, 115, 0.15);
}

.btn-submit-review {
    width: 100%;
    padding: 14px 24px;
    background: var(--msg-primary);
    color: #fff;
    border: none;
    border-radius: 24px;
    font-weight: 500;
    font-size: 0.9375rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--msg-transition);
}

.btn-submit-review:hover {
    background: #3d2e24;
}

.btn-submit-review:disabled {
    background: var(--msg-text-light);
    cursor: not-allowed;
}

/* ===========================================
   Responsive - Mobile First
   =========================================== */

@media (max-width: 768px) {
    .messages-header h1 {
        font-size: 1.5rem;
    }

    .conversation-item {
        padding: 12px 14px;
        gap: 12px;
    }

    .conv-avatar img {
        width: 52px;
        height: 52px;
    }

    .conversation-view {
        height: calc(100vh - 180px);
        min-height: 400px;
        border-radius: var(--msg-radius-sm);
    }

    .conversation-header {
        padding: 10px 14px;
    }

    .conversation-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .btn-rate {
        width: 100%;
        justify-content: center;
    }

    .messages-container {
        padding: 12px;
        gap: 6px;
    }

    .message {
        max-width: 85%;
    }

    .message-content {
        padding: 9px 12px;
        font-size: 0.9375rem;
    }

    .message-form {
        padding: 10px 14px;
    }

    .message-form textarea {
        font-size: 16px; /* Prevent iOS zoom */
        min-height: 38px;
        padding: 9px 14px;
    }

    .btn-send {
        width: 38px;
        height: 38px;
    }

    .review-modal-content {
        padding: 24px 20px;
        margin: 16px;
    }

    .rating-options {
        gap: 12px;
    }

    .rating-option {
        padding: 16px 20px;
    }

    .rating-option .rating-symbol {
        font-size: 1.75rem;
    }
}

@media (max-width: 480px) {
    .conversation-item {
        padding: 10px 12px;
    }

    .conv-avatar img {
        width: 48px;
        height: 48px;
    }

    .conv-name {
        font-size: 0.875rem;
    }

    .conv-subject,
    .conv-preview {
        font-size: 0.8125rem;
    }

    .conversation-view {
        height: calc(100vh - 140px);
        min-height: 350px;
        border-radius: 0;
    }

    .message {
        max-width: 88%;
    }

    .message-content {
        padding: 8px 11px;
        font-size: 0.875rem;
        border-radius: 16px;
    }

    .message.sent .message-content {
        border-bottom-right-radius: 4px;
    }

    .message.received .message-content {
        border-bottom-left-radius: 4px;
    }

    .empty-state {
        padding: 40px 20px;
    }

    .empty-icon {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    .empty-state h3 {
        font-size: 1.125rem;
    }

    .empty-state p {
        font-size: 0.875rem;
    }
}

/* ===========================================
   Accessibility - Reduced Motion
   =========================================== */

@media (prefers-reduced-motion: reduce) {
    .krpice-messages,
    .conversation-item,
    .conversation-view,
    .message,
    .empty-state,
    .review-modal-content,
    .krpice-toast,
    .btn-send svg {
        animation: none !important;
        transition: none !important;
    }
}
