:root {
    --primary: #2e7d32;
    --primary-light: #e8f5e9;
    --bg: #f0f2f5;
    --white: #ffffff;
    --text: #1a1a1b;
    --text-light: #65676b;
    --danger: #d32f2f;
    --danger-light: #ffebee;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --border: #e4e6eb;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    line-height: 1.4;
    overscroll-behavior-y: contain;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    background: var(--bg);
    min-height: 100vh;
}

/* Header Styles */
header {
    background: var(--white);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    height: 60px;
}

header h1 {
    font-size: 1.1rem;
    margin: 0;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Icon Buttons */
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 1.3rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:active {
    background: rgba(0, 0, 0, 0.05);
    transform: scale(0.9);
}

.icon-btn.danger {
    color: var(--danger);
}

/* Tabs Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    height: 65px;
    display: flex;
    border-top: 1px solid var(--border);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav button {
    flex: 1;
    border: none;
    background: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 0.75rem;
    gap: 4px;
    transition: color 0.2s;
}

.bottom-nav button.active {
    color: var(--primary);
    font-weight: 600;
}

.bottom-nav i {
    font-size: 1.4rem;
}

/* Views Logic */
.app-view {
    padding: 15px;
    padding-bottom: 80px;
}

/* Diary & Search */
.search-bar {
    margin-bottom: 15px;
}

#app-search-field {
    -webkit-appearance: none; /* Премахва специфични стилове за iOS/Chrome */
    width: 100%;
    padding: 14px 20px;
    border-radius: 25px;
    border: 1px solid var(--border);
    background: var(--white);
    font-size: 1rem;
    box-shadow: var(--shadow);
    transition: border-color 0.2s;
}

/* Премахва вграденото "x" в Chrome/Safari, за да не чупи нашия дизайн */
#app-search-field::-webkit-search-decoration,
#app-search-field::-webkit-search-cancel-button,
#app-search-field::-webkit-search-results-button,
#app-search-field::-webkit-search-results-decoration {
    display: none;
}

#app-search-field:focus {
    border-color: var(--primary);
}

.cards-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.card {
    background: var(--white);
    padding: 18px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    position: relative;
    border-left: 5px solid #ddd;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.card-badge {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 6px;
    color: var(--text-light);
}

.card h3 {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
}

.card p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-light);
}

.card .tags {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    font-size: 0.8rem;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Card Types */
.type-recipe { border-left-color: #4CAF50; }
.type-trick { border-left-color: #FF9800; }
.type-product { border-left-color: #2196F3; }
.type-liver { border-left-color: #9C27B0; }

/* Chat View */
#view-chat {
    position: fixed;
    top: 60px;
    bottom: 65px;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: #f0f2f5;
}

.chat-header {
    background: var(--white);
    padding: 8px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.chat-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-main {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message Bubbles */
.msg {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.msg.user {
    align-self: flex-end;
    background: var(--primary);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.msg.buddy {
    align-self: flex-start;
    background: var(--white);
    color: var(--text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.msg button {
    margin-top: 12px;
    width: 100%;
    padding: 10px;
    border-radius: 12px;
    border: 2px solid var(--primary);
    background: var(--white);
    color: var(--primary);
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Chat Input Area */
.chat-input-area {
    background: var(--white);
    padding: 12px 15px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

#chat-message-input {
    flex: 1;
    border: 1px solid var(--border);
    background: var(--bg);
    padding: 12px 18px;
    border-radius: 25px;
    font-size: 1rem;
}

#send-btn {
    background: var(--primary);
    color: var(--white);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--white);
    margin: 10% auto;
    padding: 24px;
    width: 90%;
    max-width: 450px;
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 0.85rem; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    font-size: 1rem;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 14px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
}

.load-more-container {
    text-align: center;
    margin: 20px 0;
}

.btn-secondary {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 10px 25px;
    border-radius: 20px;
    color: var(--text-light);
    font-weight: 600;
    cursor: pointer;
}

.close {
    float: right;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
}

.msg-card-actions {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.save-card-btn {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
    border: 1px dashed var(--primary) !important;
    font-size: 0.85rem !important;
    text-align: left !important;
    justify-content: flex-start !important;
    padding: 8px 12px !important;
}

.save-card-btn i {
    margin-right: 8px;
}
