/* Apple Clean Style - Collection App */

:root {
    --primary-color: #4CAF50;  /* Green button color */
    --primary-hover: #45a049;
    --primary-light: #e8f5e9;
    --secondary-color: #424242;
    --background: #ffffff;
    --surface: #f5f5f5;
    --border: #e0e0e0;
    --text-primary: #212121;
    --text-secondary: #757575;
    --error: #d32f2f;
    --warning: #f57c00;
    --success: #4CAF50;
    --info: #1976d2;

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --border-radius: 8px;
    --box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background-color: var(--background);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    min-height: 72px;
    will-change: auto;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.logo-image {
    height: 40px;
    width: auto;
    object-fit: contain;
    margin-bottom: 4px;
}

.logo-text {
    font-size: 13px;
    font-weight: 400;
    color: #666;
    text-align: center;
    line-height: 1.2;
}

.logo-subtext {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Navigation */
.nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-link {
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: color 0.2s ease, border-color 0.2s ease;
    display: inline-block;
    position: relative;
    border-bottom: 2px solid transparent;
    font-weight: 500;
}

.nav-link:hover {
    color: var(--text-primary);
}

.nav-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Tabs Navigation (for internal page tabs) */
.tabs-header {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.tab-link {
    padding: 12px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-size: 14px;
    font-weight: 500;
}

.tab-link:hover {
    color: var(--text-primary);
}

.tab-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Dropdown Navigation */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-dropdown-toggle {
    cursor: pointer;
    user-select: none;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    z-index: 1000;
}

.nav-dropdown:hover .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-item {
    display: block;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--text-primary);
    transition: background-color 0.2s ease;
}

.nav-dropdown-item:hover {
    background-color: var(--surface);
}

.nav-dropdown-item:first-child {
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.nav-dropdown-item:last-child {
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* Скрыть меню адміністрування для не-админов */
body:not([data-user-role="admin"]) #templates-link,
body:not([data-user-role="admin"]) #users-link {
    display: none;
}

/* Page description */
.page-description {
    margin-bottom: 24px;
    padding: 16px 20px;
    background-color: #f8f9fa;
    border-left: 4px solid var(--primary-color);
    border-radius: 4px;
}

.page-description p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: #555;
}

/* User menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-email {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--surface);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--border);
}

.btn-danger {
    background-color: var(--error);
    color: white;
}

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

.btn-warning {
    background-color: #ffcc80;
    color: white;
}

.btn-warning:hover {
    background-color: #ffb74d;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Cards */
.card {
    background-color: var(--background);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 24px;
    margin-bottom: 20px;
}

.card-header {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: var(--font-family);
    transition: var(--transition);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--background);
}

.table thead {
    background-color: var(--surface);
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
    text-transform: capitalize;
    letter-spacing: 0;
}

.table td {
    font-size: 14px;
    font-weight: 400;
}

.table tbody tr:hover {
    background-color: var(--surface);
}

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

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background-color: #e8f5e9;
    color: var(--success);
}

.badge-danger {
    background-color: #ffebee;
    color: #ef9a9a;
}

.badge-warning {
    background-color: #fff3e0;
    color: #ffcc80;
}

.badge-info {
    background-color: #e3f2fd;
    color: #90caf9;
}

/* Status Icon */
.status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    cursor: help;
    position: relative;
}

.status-icon.success {
    background-color: #a5d6a7;
    color: white;
}

/* Кастомный tooltip для мгновенного показа */
.status-icon[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: normal;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    animation: fadeIn 0.1s ease-in;
}

.status-icon[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% - 1px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    pointer-events: none;
    animation: fadeIn 0.1s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Email links */
.email-link {
    color: var(--text-primary);
    text-decoration: none;
}

.email-link:hover {
    text-decoration: underline;
}

/* Alerts - Toast Style */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert {
    padding: 14px 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    max-width: 450px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.alert.fade-out {
    animation: slideOut 0.3s ease-in forwards;
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.alert-success {
    background-color: #e8f5e9;
    color: var(--success);
    border-left: 4px solid var(--success);
}

.alert-error {
    background-color: #ffebee;
    color: var(--error);
    border-left: 4px solid var(--error);
}

.alert-warning {
    background-color: #fff3e0;
    color: var(--warning);
    border-left: 4px solid var(--warning);
}

.alert-info {
    background-color: #e3f2fd;
    color: var(--info);
    border-left: 4px solid var(--info);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 10001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--background);
    border-radius: var(--border-radius);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    background-color: var(--surface);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Loader */
.loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

.loader.show {
    display: inline-block;
}

/* Upload progress - hidden by default */
#upload-progress {
    display: none;
}

/* Dropdown menu for actions */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    min-width: 32px;
    padding: 4px 8px;
    font-size: 18px;
    line-height: 1;
    font-weight: bold;
}

.dropdown-menu {
    display: none;
    position: fixed;
    background-color: white;
    min-width: 150px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    border-radius: 4px;
    z-index: 9999;
    border: 1px solid #e0e0e0;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 8px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
}

.dropdown-item:hover {
    background-color: #f5f5f5;
}

.dropdown-item:first-child {
    border-radius: 4px 4px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 4px 4px;
}

/* Split button dropdown */
.mailing-btn-split {
    display: inline-flex;
    gap: 0;
}

.mailing-btn-split .dropdown-toggle-split {
    padding-left: 12px;
    padding-right: 12px;
    margin-left: -1px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
}

.mailing-btn-split .btn:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.mailing-btn-split .dropdown-menu {
    min-width: 280px;
}

.mailing-btn-split .dropdown-item small {
    display: block;
    font-size: 12px;
    margin-top: 2px;
    line-height: 1.3;
}

/* Badge styles */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
}

.badge-primary {
    background-color: #e3f2fd;
    color: #90caf9;
}

.badge-danger {
    background-color: #ffebee;
    color: #ef9a9a;
}

.badge-warning {
    background-color: #fff3e0;
    color: #ffcc80;
}

/* Spinner */
.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Login page logo */
.login-logo-image {
    height: 80px;
    width: auto;
    object-fit: contain;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

/* Main content */
.main-content {
    padding: 32px 0;
    flex: 1;
}

/* Footer */
.footer {
    background-color: #424242;
    border-top: 1px solid #333;
    padding: 20px 0;
    text-align: center;
    color: #b0b0b0;
    font-size: 13px;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination .btn {
    min-width: 36px;
}
