/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

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

/* Custom Multi-Select Component */
.custom-multiselect {
    position: relative;
    width: 100%;
}

.multiselect-trigger {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 44px; /* Touch-friendly height for mobile */
    font-size: 14px;
}

.multiselect-trigger:hover {
    border-color: #007bff;
}

.multiselect-trigger.active {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.multiselect-trigger .placeholder {
    color: #999;
}

.multiselect-trigger .selection-text {
    color: #333;
    flex: 1;
    text-align: left;
}

.multiselect-trigger .arrow {
    margin-left: 8px;
    font-size: 12px;
    color: #666;
    transition: transform 0.2s;
}

.multiselect-trigger.active .arrow {
    transform: rotate(180deg);
}

.multiselect-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.multiselect-dropdown.active {
    display: block;
}

.multiselect-search {
    padding: 12px;
    border-bottom: 1px solid #eee;
}

.multiselect-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.multiselect-options {
    padding: 8px 0;
}

.multiselect-option {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    min-height: 44px; /* Touch-friendly height */
    transition: background-color 0.2s;
}

.multiselect-option:hover {
    background-color: #f8f9fa;
}

.multiselect-option.selected {
    background-color: #e3f2fd;
}

.multiselect-option input[type="checkbox"] {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.multiselect-option label {
    flex: 1;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
}

.multiselect-actions {
    padding: 12px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.multiselect-action-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    min-height: 32px;
}

.multiselect-action-btn:hover {
    background-color: #f8f9fa;
}

.multiselect-action-btn.primary {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.multiselect-action-btn.primary:hover {
    background-color: #0056b3;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .multiselect-trigger {
        min-height: 48px; /* Larger touch targets on mobile */
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .multiselect-option {
        min-height: 48px;
        font-size: 16px;
    }
    
    .multiselect-option input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }
    
    .multiselect-dropdown {
        max-height: 250px; /* Shorter on mobile */
    }
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
    color: #2c3e50;
    margin-bottom: 10px;
}

header p {
    color: #666;
    font-size: 16px;
}

/* Navigation */
.navigation {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    justify-content: center;
}

.nav-btn {
    padding: 12px 24px;
    border: none;
    background: white;
    color: #666;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-btn:hover {
    background: #f8f9fa;
    transform: translateY(-1px);
}

.nav-btn.active {
    background: #007bff;
    color: white;
}

/* Content sections */
.content-section {
    display: none;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.section-header h2 {
    color: #2c3e50;
    font-size: 24px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
}

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

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-cancel {
    background: #6c757d;
    color: white;
}

.btn-cancel:hover {
    background: #545b62;
}

.btn-danger {
    background: #dc3545;
    color: white;
    font-size: 12px;
    padding: 6px 12px;
}

.btn-danger:hover {
    background: #c82333;
}

/* Forms */
.form-container {
    margin-top: 30px;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.form-container h3 {
    margin-bottom: 25px;
    color: #2c3e50;
}

.item-form {
    max-width: 800px;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.form-group small {
    display: block;
    margin-top: 4px;
    color: #666;
    font-size: 12px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* Multi-select styling */
select[multiple] {
    min-height: 100px;
    padding: 8px;
}

select[multiple] option {
    padding: 4px 8px;
    margin-bottom: 2px;
}

select[multiple] option:checked {
    background: #007bff;
    color: white;
}

/* Form sections */
.form-section {
    margin-top: 30px;
    padding: 20px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.form-section h4 {
    margin-bottom: 15px;
    color: #495057;
}

.form-section .section-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

/* Dynamic items (tickets, subscriptions) */
.ticket-item,
.subscription-item {
    margin-bottom: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    position: relative;
}

.ticket-item h5,
.subscription-item h5 {
    margin-bottom: 15px;
    color: #495057;
}

.ticket-item .remove-ticket,
.subscription-item .remove-subscription {
    position: absolute;
    top: 10px;
    right: 10px;
}

/* Form actions */
.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* Items list */
.items-list {
    display: grid;
    gap: 15px;
}

.item-card {
    background: white;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    transition: all 0.3s ease;
}

.item-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.item-card.inactive {
    background: #fff5f5;
    border-color: #fed7d7;
    opacity: 0.8;
}

.item-card.inactive:hover {
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.15);
    border-color: #fc8181;
}

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

.item-title {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.item-meta {
    color: #666;
    font-size: 14px;
    margin-bottom: 10px;
}

.item-description {
    color: #555;
    line-height: 1.5;
    margin-bottom: 15px;
}

.item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 15px;
}

.tag {
    background: #e9ecef;
    color: #495057;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.tag.featured {
    background: #ffd43b;
    color: #856404;
}

.tag.enabled {
    background: #d4edda;
    color: #155724;
}

.tag.disabled {
    background: #f8d7da;
    color: #721c24;
}

.item-actions {
    display: flex;
    gap: 10px;
}

/* Loading and messages */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* Toast notifications */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    min-width: 280px;
    max-width: 420px;
    padding: 14px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.hide {
    opacity: 0;
    transform: translateY(12px);
}

.toast.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.toast.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.toast-icon {
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1.4;
}

.toast-message {
    flex: 1;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    opacity: 0.5;
    padding: 0;
    color: inherit;
}

.toast-close:hover {
    opacity: 1;
}

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

.text-muted {
    color: #6c757d;
}

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

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .navigation {
        flex-direction: column;
        align-items: center;
    }
    
    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .item-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .item-actions {
        justify-content: flex-start;
    }
}

/* Focus states for accessibility */
.btn:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Ticket and Subscription Actions */
.ticket-actions,
.subscription-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.ticket-status,
.subscription-status {
    font-size: 12px;
    font-weight: bold;
    margin-left: 5px;
}

.save-ticket,
.save-subscription {
    background: #28a745;
    color: white;
}

.save-ticket:hover,
.save-subscription:hover {
    background: #218838;
}

.ticket-item[data-ticket-id=""] .ticket-status::before,
.subscription-item[data-subscription-id=""] .subscription-status::before {
    content: "⚠ Unsaved";
    color: #ffc107;
    font-weight: bold;
}

.ticket-item[data-ticket-id]:not([data-ticket-id=""]) .save-ticket,
.subscription-item[data-subscription-id]:not([data-subscription-id=""]) .save-subscription {
    background: #007bff !important;
}

.ticket-item[data-ticket-id]:not([data-ticket-id=""]) .save-ticket:hover,
.subscription-item[data-subscription-id]:not([data-subscription-id=""]) .save-subscription:hover {
    background: #0056b3 !important;
}

/* Smooth transitions */
* {
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

/* File Manager Styles */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.file-card {
    background: white;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.file-thumbnail {
    width: 100%;
    height: 150px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.file-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-thumbnail video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-thumbnail .video-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

.file-info {
    padding: 12px;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-meta {
    font-size: 12px;
    color: #666;
}

.file-type-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #e9ecef;
    border-radius: 12px;
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 600;
    margin-right: 8px;
}

.file-type-badge.image {
    background: #d4edda;
    color: #155724;
}

.file-type-badge.video {
    background: #cce5ff;
    color: #004085;
}

/* File Preview in Form */
.file-preview {
    margin: 15px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.file-preview h4 {
    margin-bottom: 10px;
    color: #495057;
}

#file-preview img,
#file-preview video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 4px;
}

/* Upload Progress */
.upload-progress {
    margin: 15px 0;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    border-radius: 10px;
    transition: width 0.3s ease;
    width: 0%;
}

#progress-text {
    font-size: 14px;
    color: #666;
}

/* File Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 900px;
    max-height: 90vh;
    width: 90%;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 30px;
    cursor: pointer;
    color: #666;
    z-index: 10;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-preview {
    flex: 1;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-height: 300px;
    max-height: 50vh;
    overflow: hidden;
}

.modal-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.modal-preview video {
    max-width: 100%;
    max-height: 100%;
}

.modal-info {
    padding: 25px;
    background: white;
}

.modal-info h3 {
    margin-bottom: 10px;
    color: #333;
    word-break: break-all;
}

.modal-info p {
    color: #666;
    margin-bottom: 15px;
}

.modal-url-container {
    margin: 15px 0;
}

.modal-url-container label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #555;
}

.modal-url-container input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: #f8f9fa;
    margin-bottom: 10px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* Empty state */
.files-empty {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.files-empty-icon {
    font-size: 60px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.files-empty h3 {
    margin-bottom: 10px;
    color: #495057;
}

/* Drag and drop styling */
.file-drop-zone {
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    background: #f8f9fa;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.file-drop-zone.dragover {
    border-color: #007bff;
    background: #e3f2fd;
}

.file-drop-zone-icon {
    font-size: 48px;
    color: #adb5bd;
    margin-bottom: 15px;
}

.file-drop-zone p {
    color: #666;
    margin-bottom: 15px;
}

/* Responsive for file manager */
@media (max-width: 768px) {
    .files-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }
    
    .file-thumbnail {
        height: 120px;
    }
    
    .modal-content {
        max-height: 95vh;
        width: 95%;
    }
    
    .modal-preview {
        min-height: 200px;
    }
    
    .modal-actions {
        flex-direction: column;
    }
}

/* --- Auth & staff UI (Phase A3) --- */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
}

.login-card {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 360px;
    width: 90%;
}

.login-card h1 { margin: 0 0 8px; }
.login-card p { color: #555; margin: 0 0 20px; }
.login-card #google-signin-btn { display: flex; justify-content: center; }
.login-error { color: #c0392b; min-height: 1.2em; margin-top: 12px; }

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-email { font-weight: 600; }
.user-role {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    background: #2d2d44;
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
}

.staff-add-form { margin-bottom: 20px; }
.staff-add-btn-group { display: flex; align-items: flex-end; }

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

.staff-info { display: flex; align-items: center; gap: 10px; }
.staff-role-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    background: #eee;
    padding: 2px 8px;
    border-radius: 10px;
}
.staff-actions { display: flex; gap: 8px; }

.btn-small {
    padding: 4px 10px;
    font-size: 0.85rem;
}
.btn-small:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.txn-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.txn-info { flex: 1; min-width: 0; }
.txn-meta { font-size: 0.85rem; color: #555; margin-top: 2px; }
.txn-ids { font-size: 0.75rem; color: #888; word-break: break-all; }
.txn-status {
    font-size: 0.7rem;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    background: #eee;
}
.txn-CONFIRMED { background: #d4edda; color: #155724; }
.txn-FAILED { background: #f8d7da; color: #721c24; }
.txn-REFUNDED, .txn-REFUND_PENDING { background: #fff3cd; color: #856404; }
.txn-actions { flex-shrink: 0; }
}