/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@font-face {
    font-family: 'FrutigerNeueLTW1G';
    src: url('/fonts/FrutigerNeueLTW1G/FrutigerNeueLTW1G-Regular.woff2') format('woff2'),
         url('/fonts/FrutigerNeueLTW1G/FrutigerNeueLTW1G-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Novacutan-inspired brand palette */
    --primary-color: #5C2E7E;      /* основной фиолетово-сливовый акцент */
    --secondary-color: #8A7BA5;    /* мягкий лилово-серый для второстепенных элементов */
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --light-bg: #f5f5f5;           /* светлый фон в духе novacutan.ru */
    --border-color: #E1DBF0;       /* нежные границы/разделители */
    --text-color: #1E1E1E;         /* тёмный "виноградный" текст */
    --card-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

body {
    font-family: 'FrutigerNeueLTW1G', 'Frutiger Neue LT W1G', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-color);
    line-height: 1.6;
    padding: 0;
    margin: 0;
}

.main-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-layout-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: 800rem; /* увеличенный отступ снизу под фиксированной кнопкой */
}

/* Header */
.header {
    background: white;
    padding: 1rem;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.header h1 {
    flex: 1;
    font-size: 1.5rem;
    margin: 0;
}

/* Top auth bar with login/register buttons */
.top-auth-bar {
    background: white;
    padding: 0.5rem 1rem;
    box-shadow: var(--card-shadow);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.top-auth-bar .btn {
    padding: 0.4rem 0.9rem;
    font-size: 0.875rem;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 1rem;
}

.card h1 {
    margin-bottom: 1rem;
    font-size: 1.75rem;
}

.card h2 {
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-grid .card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card-grid .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Forms */
form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

input, textarea, select {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    background-color: #333333;
    color: #FFFFFF;
    transition: background-color 0.2s, transform 0.1s;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: #333333;
    color: #FFFFFF;
}

.btn-primary:hover {
    background-color: #333333;
}

.btn-secondary {
    background-color: #333333;
    color: #FFFFFF;
}

.btn-secondary:hover {
    background-color: #333333;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

button[type="submit"] {
    background-color: #333333;
    color: #FFFFFF;
    padding: 0.75rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
}

button[type="submit"]:hover {
    background-color: #333333;
}

/* Login Card */
.login-card {
    max-width: 400px;
    margin: 2rem auto;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 2rem;
}

/* Verification Card */
.verification-card {
    max-width: 600px;
    margin: 1rem auto;
}

.verification-section {
    margin-bottom: 2rem;
}

.verification-section.hidden {
    display: none;
}

.success-message {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    padding: 1.5rem;
    color: #155724;
}

.error-message {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 1rem;
    color: #721c24;
    margin-bottom: 1rem;
}

.error-message.hidden {
    display: none;
}

.product-info {
    margin-top: 1rem;
}

.product-info p {
    margin: 0.5rem 0;
}

.code-info {
    font-size: 0.875rem;
    color: var(--secondary-color);
    margin-top: 0.5rem;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    margin-top: 1rem;
}

/* Table wrapper with scrollbar on top */
.table-wrapper-top-scroll {
    position: relative;
    margin-top: 1rem;
}

.table-scroll-top {
    width: 100%;
    height: 17px;
    overflow-x: auto;
    overflow-y: hidden;
    direction: rtl;
    margin-bottom: 0;
    border-bottom: 1px solid #ddd;
}

.table-scroll-top > div {
    width: 1px;
    height: 1px;
}

.table-wrapper-inner {
    overflow-x: auto;
    overflow-y: visible;
    max-height: 70vh;
    width: 100%;
}

/* Show bottom scrollbar but sync with top */
.table-wrapper-top-scroll .table-wrapper-inner {
    overflow-x: scroll;
    overflow-y: auto;
}

/* Show and style top scrollbar */
.table-wrapper-top-scroll .table-scroll-top::-webkit-scrollbar {
    height: 12px;
}

.table-wrapper-top-scroll .table-scroll-top::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 6px;
}

.table-wrapper-top-scroll .table-scroll-top::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.table-wrapper-top-scroll .table-scroll-top::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    background-color: var(--light-bg);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table th:hover {
    background-color: #e9ecef;
}

.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:hover {
    background-color: #f8f9fa;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Table Controls */
.table-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.table-controls input {
    flex: 1;
    min-width: 200px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    color: #333333;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: #333333;
}

.tab-btn.active {
    color: #333333;
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: block;
}

.tab-content.hidden {
    display: none;
}

/* Таблица QR-кодов в генераторе */
.qr-code-row.scanned {
    background-color: #e8f5e9;
}

/* Modal */
.modal {
    display: flex;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    font-weight: bold;
    color: var(--secondary-color);
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: var(--text-color);
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Progress Indicator */
.progress-indicator {
    background-color: var(--light-bg);
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    text-align: center;
}

/* URLs List */
.urls-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    margin: 1rem 0;
}

.url-item {
    padding: 0.5rem;
    margin: 0.25rem 0;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.url-item.scanned {
    background-color: #d4edda;
}

.url-item.unscanned {
    background-color: #f8d7da;
}

/* QR Codes Grid */
.qr-codes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.qr-code-item {
    text-align: center;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.qr-code-item img {
    max-width: 100%;
    height: auto;
}

.qr-code-item .code-text {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    word-break: break-all;
}

/* Fixed scan QR button on client dashboard */
.fixed-scan-btn {
    position: fixed;
    left: 50%;
    bottom: 1rem;           /* подняли кнопку выше низа экрана */
    transform: translateX(-50%);
    z-index: 1500;
    padding: 1rem 2.5rem;
    font-size: 1.05rem;
    background-color: #333333;
    border-radius: 999px;
}

.fixed-scan-btn:hover {
    background-color: #333333;
}

/* Не даём общей анимации .btn:hover сдвигать фиксированную кнопку */
.fixed-scan-btn,
.fixed-scan-btn:hover,
.fixed-scan-btn:active {
    transform: translateX(-50%);
}
/* Button to mark product as used in LK */
.product-mark-used-btn {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
}

/* Drug description in admin drugs table */
.drug-description {
    max-height: 6.5em; /* примерно 4-5 строк */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    position: relative;
}

.drug-description.expanded {
    max-height: none;
    -webkit-line-clamp: unset;
}

.drug-description-toggle {
    margin-top: 0.25rem;
    padding: 0;
    border: none;
    background: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: underline;
}

/* Separator between drugs rows in admin drugs table */
.drugs-table tbody tr {
    border-bottom: 2px solid var(--border-color);
}

.drugs-table tbody tr + tr {
    border-top: 1px solid #fff;
}

/* Danger button (e.g. delete client) */
.btn-danger {
    background-color: #333333;
    color: #FFFFFF;
}

.btn-danger:hover {
    background-color: #333333;
}

/* Global loading overlay */
.page-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.page-overlay.hidden {
    display: none;
}

/* Loader made of small circles */
.loader {
    position: relative;
    width: 60px;
    height: 60px;
}

.loader::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    border-radius: 50%;
    background-color: var(--primary-color);
    box-shadow:
        20px 0 0 rgba(92, 46, 126, 0.9),
        14px 14px 0 rgba(92, 46, 126, 0.7),
        0 20px 0 rgba(92, 46, 126, 0.5),
        -14px 14px 0 rgba(92, 46, 126, 0.4),
        -20px 0 0 rgba(92, 46, 126, 0.3),
        -14px -14px 0 rgba(92, 46, 126, 0.2),
        0 -20px 0 rgba(92, 46, 126, 0.15),
        14px -14px 0 rgba(92, 46, 126, 0.1);
    animation: loader-rotate 0.9s linear infinite;
}

@keyframes loader-rotate {
    to {
        transform: rotate(360deg);
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }
    
    .header {
        padding: 0.75rem;
    }
    
    .header h1 {
        font-size: 1.25rem;
        width: 100%;
    }
    
    .card {
        padding: 1rem;
    }
    
    .data-table {
        font-size: 0.75rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }
    
    .modal-content {
        padding: 1rem;
        margin: 0.5rem;
    }
    
    .table-controls {
        flex-direction: column;
    }
    
    .table-controls input {
        width: 100%;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    .qr-codes-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    /* Hide less important columns on mobile */
    .data-table th:nth-child(n+6),
    .data-table td:nth-child(n+6) {
        display: none;
    }
    
    /* Show actions column */
    .data-table th:last-child,
    .data-table td:last-child {
        display: table-cell;
    }
}

@media (max-width: 480px) {
    .header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .header .btn {
        width: 100%;
        margin: 0.25rem 0;
    }
    
    .card h1 {
        font-size: 1.5rem;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        border-bottom: none;
        border-left: 2px solid transparent;
        padding-left: 1rem;
    }
    
    .tab-btn.active {
        border-left-color: var(--primary-color);
        border-bottom-color: transparent;
    }
}

/* Print Styles */
@media print {
    .header,
    .table-controls,
    .btn,
    .form-actions {
        display: none;
    }
    
    .data-table {
        font-size: 0.7rem;
    }
}

/* Email test page styles */
.email-test-section {
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    margin-bottom: 20px;
    background: white;
}

.email-test-section h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

.test-result {
    margin-top: 15px;
    padding: 10px;
}

.test-result.hidden {
    display: none;
}

.smtp-settings {
    background: var(--light-bg);
    padding: 15px;
    border-radius: 5px;
    margin-top: 10px;
}

.smtp-settings p {
    margin: 8px 0;
    padding: 5px 0;
    border-bottom: 1px solid var(--border-color);
}

.smtp-settings p:last-child {
    border-bottom: none;
}

.smtp-settings strong {
    display: inline-block;
    width: 200px;
    color: var(--text-color);
}

/* Cookie Consent Banner */
.cookie-consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    padding: 1rem;
    z-index: 10000;
    border-top: 2px solid var(--primary-color);
}

.cookie-consent-banner.hidden {
    display: none;
}

.cookie-consent-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.cookie-consent-content p {
    margin: 0;
    flex: 1;
    min-width: 250px;
}

.cookie-consent-content a {
    color: var(--primary-color);
    text-decoration: underline;
}

.cookie-consent-buttons {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .cookie-consent-content {
        flex-direction: column;
        text-align: center;
    }
    
    .cookie-consent-buttons {
        width: 100%;
        justify-content: center;
    }
}