/* style.css (v3) - Обновлённый дизайн */
:root {
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #111111;
    --muted: #64748b;
    --primary-color: #3b82f6; /* Tailwind blue-500 */
    --error-color: #ef4444;   /* Tailwind red-500 */
    --warning-color: #eab308; /* Tailwind yellow-500 */
    --info-color: #0ea5e9;    /* Tailwind sky-500 */
    --success-color: #22c55e; /* Tailwind green-500 */
    --border-color: #cbd5e1;  /* Tailwind gray-300 */
    --header-bg: #1d4ed8;     /* Tailwind blue-700 */
    --nav-bg: #ffffff;
    --nav-text: #475569;      /* Tailwind gray-600 */
    --nav-active-bg: #dbeafe; /* Tailwind blue-200 */
    --nav-active-text: var(--primary-color);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --transition-fast: all 0.2s ease-in-out;
    --radius: 12px;
    --radius-sm: 8px;
}

html, body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary-color);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* Header */
header {
    background-color: var(--header-bg);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.header-left h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-name {
    font-weight: 500;
}

.btn-logout {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition-fast);
}
.btn-logout:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: white;
}
.btn-logout svg {
    stroke: white;
}

/* Navigation */
nav {
    background-color: var(--nav-bg);
    padding: 10px 20px;
    box-shadow: var(--shadow-sm);
    display: none; /* Initially hidden, shown after auth */
    justify-content: center;
    overflow-x: auto; /* For mobile scrolling */
    white-space: nowrap;
}

nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 5px;
}

.nav-btn {
    background: none;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--nav-text);
    font-weight: 500;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-btn:hover {
    background-color: var(--nav-active-bg);
    color: var(--nav-active-text);
}
.nav-btn.active {
    background-color: var(--nav-active-bg);
    color: var(--nav-active-text);
    font-weight: 700;
}

/* Main Content Area */
main {
    padding: 20px;
    max-width: 960px;
    margin: 20px auto;
}

.view {
    background: var(--card);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}

.view h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
}

.placeholder-text {
    color: var(--muted);
    font-style: italic;
    text-align: center;
    padding: 30px 0;
}

/* Auth Prompt */
#auth-prompt {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}
.auth-card {
    background: var(--card);
    border-radius: 12px;
    padding: 35px;
    text-align: center;
    box-shadow: var(--shadow-md);
    max-width: 450px;
    width: 100%;
}
.auth-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}
.auth-card h2 {
    font-size: 2rem;
    margin-bottom: 5px;
    color: var(--primary-color);
}
.auth-card p {
    margin-bottom: 15px;
    color: var(--muted);
}
.auth-hint {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 25px;
}
#telegram-widget-placeholder {
    display: inline-block; /* To allow telegram widget to render inside */
}
.tg-login { display: inline-block !important; } /* Ensure Telegram button fits */

/* Form Styles */
#data-entry-form {
    display: grid;
    gap: 15px;
    max-width: 450px;
    margin: 0 auto;
}
.form-field {
    position: relative;
    margin-bottom: 5px; /* Less space between fields, error message provides spacing */
}
.form-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 0.95rem;
}
.form-field input[type="text"],
.form-field input[type="number"],
.form-field textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-field input:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2); /* Tailwind blue-300 glow */
}

.form-field input.input-error,
.form-field textarea.input-error {
    border-color: var(--error-color);
}
.form-field input.input-error:focus,
.form-field textarea.input-error:focus {
    border-color: var(--error-color);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2); /* Tailwind red-300 glow */
}

.field-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 4px;
}
.error-message {
    display: block;
    color: var(--error-color);
    font-size: 0.8rem;
    margin-top: 4px;
    min-height: 1em; /* Prevents layout shifts */
}

/* Submit Button */
.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%; /* Full width within form */
}
.btn-primary:hover:not(:disabled) {
    background-color: #1d4ed8; /* Darker blue */
}
.btn-primary:disabled {
    background-color: var(--primary-color);
    opacity: 0.7;
    cursor: not-allowed;
}
.btn-primary .btn-loader {
    display: none; /* Initially hidden */
    align-items: center;
    gap: 10px;
}
.btn-primary .spinner {
    animation: spin 1s linear infinite;
    color: white;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background-color: white;
    color: var(--text);
    padding: 12px 18px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out, opacity 0.6s ease-in 0.2s;
    border-left: 5px solid;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 350px;
    word-wrap: break-word;
}
.toast-icon { font-size: 1.2rem; }

/* Toast Colors */
.toast-info { border-left-color: var(--info-color); }
.toast-success { border-left-color: var(--success-color); }
.toast-warning { border-left-color: var(--warning-color); }
.toast-error { border-left-color: var(--error-color); }

.toast-show {
    opacity: 1;
    transform: translateY(0);
}
.toast-hide {
    opacity: 0;
    transform: translateY(-20px);
}

/* Misc */
footer {
    text-align: center;
    padding: 20px;
    color: var(--muted);
    font-size: 0.9rem;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        padding: 10px;
    }
    .header-right {
        margin-top: 10px;
        width: 100%;
        justify-content: space-between;
    }
    .header-left h1, .user-name { font-size: 1.2rem; }
    .btn-logout { padding: 6px 10px; font-size: 0.8rem;}

    nav ul {
        flex-wrap: nowrap; /* Prevent wrapping, enable scrolling */
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .nav-btn { padding: 8px 12px; font-size: 0.9rem; }

    main {
        padding: 15px;
    }
    .view {
        padding: 20px;
    }
    .auth-card {
        padding: 25px;
    }
    .auth-card h2 { font-size: 1.6rem; }
    .auth-hint { font-size: 1rem; }

    #toast-container {
        top: 10px;
        right: 10px;
        left: 10px; /* Allow toasts to span on small screens */
        align-items: center;
    }
    .toast {
        width: calc(100% - 20px); /* Max width for toasts */
        max-width: 400px;
    }
}
