/* ========================================
   Pattern Library Modal Styles
   ======================================== */

.library-modal-content {
    max-width: 1000px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.library-tabs {
    display: flex;
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
}

.library-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
    position: relative;
}

.library-tab:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.library-tab.active {
    background: white;
    color: var(--primary);
}

.library-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.library-tab .badge {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
}

.library-body {
    padding: 0;
    overflow: hidden;
}

.library-pane {
    display: none;
    height: 100%;
}

.library-pane.active {
    display: flex;
    flex-direction: column;
}

.library-toolbar {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.search-input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 0.95em;
    font-family: var(--font-family);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-select {
    padding: 10px 16px;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 0.95em;
    background: white;
    cursor: pointer;
    font-family: var(--font-family);
}

/* Sign In Prompt */
.sign-in-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.prompt-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

.sign-in-prompt h3 {
    margin: 0 0 12px 0;
    color: var(--gray-900);
}

.sign-in-prompt p {
    color: var(--gray-600);
    margin-bottom: 24px;
}

/* Folder List */
.folder-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.folder-item:hover {
    border-color: var(--primary);
    background: var(--gray-50);
}

.folder-item.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.folder-icon {
    font-size: 1.2em;
}

.folder-name {
    font-weight: 500;
}

.folder-count {
    background: var(--gray-200);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8em;
}

.folder-item.active .folder-count {
    background: rgba(255, 255, 255, 0.3);
}

.folder-delete {
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 1.2em;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0;
    transition: all 0.2s;
}

.folder-item:hover .folder-delete {
    opacity: 1;
}

.folder-delete:hover {
    color: var(--danger);
}

/* Pattern List */
.pattern-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.pattern-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.pattern-item:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
}

.pattern-icon {
    font-size: 2em;
}

.pattern-info {
    flex: 1;
}

.pattern-name {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.pattern-meta {
    font-size: 0.85em;
    color: var(--gray-600);
}

.pattern-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-100);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1em;
}

.btn-icon:hover {
    background: var(--primary);
    transform: scale(1.1);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--gray-500);
}

.empty-icon {
    font-size: 4em;
    margin-bottom: 16px;
}

.empty-state p {
    margin: 4px 0;
}

.empty-hint {
    font-size: 0.9em;
    color: var(--gray-400);
}

.local-info {
    padding: 12px 16px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.9em;
    color: var(--gray-600);
}

/* ========================================
   Admin Panel Modal Styles
   ======================================== */

.admin-modal-content {
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.admin-tabs {
    display: flex;
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
}

.admin-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
    position: relative;
}

.admin-tab:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.admin-tab.active {
    background: white;
    color: var(--primary);
}

.admin-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.admin-body {
    padding: 0;
    overflow: hidden;
}

.admin-pane {
    display: none;
    padding: 24px;
    overflow-y: auto;
}

.admin-pane.active {
    display: block;
}

.admin-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

/* Admin Table */
.admin-table-container {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.admin-table th {
    text-align: left;
    padding: 12px;
    background: var(--gray-100);
    color: var(--gray-700);
    font-weight: 600;
    border-bottom: 2px solid var(--gray-300);
}

.admin-table td {
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.admin-table tr:hover {
    background: var(--gray-50);
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
}

.badge-admin {
    background: var(--primary);
    color: white;
}

.badge-user {
    background: var(--gray-300);
    color: var(--gray-700);
}

.badge-premium {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.badge-free {
    background: var(--gray-200);
    color: var(--gray-700);
}

.loading, .error, .empty {
    text-align: center;
    padding: 40px;
    color: var(--gray-500);
}

.error {
    color: var(--danger);
}

/* Forms */
.credit-form {
    max-width: 600px;
    margin: 0 auto;
    padding: 24px;
    background: var(--gray-50);
    border-radius: 12px;
}

.credit-form h3 {
    margin: 0 0 20px 0;
    color: var(--gray-900);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.9em;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 0.95em;
    font-family: var(--font-family);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    transition: all 0.2s;
}

.stat-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.1);
}

.stat-icon {
    font-size: 2.5em;
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 0.85em;
    color: var(--gray-600);
}

.stat-value {
    font-size: 2em;
    font-weight: 700;
    color: var(--primary);
}

.top-users {
    margin-top: 32px;
}

.top-users h3 {
    margin: 0 0 16px 0;
    color: var(--gray-900);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .library-modal-content,
    .admin-modal-content {
        width: 95%;
        max-width: none;
    }

    .library-tabs,
    .admin-tabs {
        overflow-x: auto;
    }

    .library-tab,
    .admin-tab {
        flex: 0 0 auto;
        min-width: 120px;
    }

    .tab-text {
        display: none;
    }

    .folder-list {
        overflow-x: auto;
    }

    .admin-table {
        font-size: 0.8em;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
