/* public/css/categories.css */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f8fafc;
    color: #334155;
    font-size: 14px;
    line-height: 1.5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.title {
    font-size: 28px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 14px;
    color: #64748b;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Button Styles */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-primary {
    background: #6366f1;
    color: white;
}

.btn-primary:hover {
    background: #5855eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Filter Styles */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    transition: all 0.2s ease;
    min-width: 150px;
}

.filter-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.advanced-filters {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.advanced-filters-content {
    padding: 16px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.date-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Grid Layout */
.categories-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 24px;
}

@media (max-width: 1200px) {
    .categories-grid {
        grid-template-columns: 1fr;
    }
}

/* Categories List */
.categories-list {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
}

.category-item {
    padding: 20px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: move;
    transition: all 0.2s ease;
    position: relative;
}

.category-item:last-child {
    border-bottom: none;
}

.category-item:hover {
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.category-item.sortable-chosen {
    background: #f0f9ff;
    box-shadow: inset 0 0 0 2px #3b82f6;
}

.category-item.sortable-drag {
    opacity: 0.8;
    transform: rotate(2deg);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.category-handle {
    color: #94a3b8;
    cursor: grab;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s ease;
}

.category-handle:hover {
    color: #64748b;
}

.category-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.category-info {
    flex: 1;
    min-width: 0;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.category-name {
    font-weight: 600;
    font-size: 16px;
    color: #1e293b;
}

.children-count {
    padding: 2px 6px;
    background: #e2e8f0;
    color: #64748b;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.category-meta {
    margin-bottom: 8px;
}

.category-path {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
}

.category-description {
    font-size: 13px;
    color: #6b7280;
}

.category-stats {
    display: flex;
    gap: 12px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #94a3b8;
}

.category-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-inactive {
    background: #fecaca;
    color: #991b1b;
}

/* Action Dropdown */
.category-actions {
    position: relative;
}

.action-dropdown {
    position: relative;
}

.dropdown-toggle {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: #f1f5f9;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.dropdown-toggle:hover {
    background: #e2e8f0;
    transform: scale(1.05);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    z-index: 100;
    min-width: 160px;
    padding: 6px 0;
    display: none;
}

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

.dropdown-item {
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s ease;
}

.dropdown-item:hover {
    background: #f9fafb;
}

.dropdown-item.danger {
    color: #dc2626;
}

.dropdown-item.danger:hover {
    background: #fef2f2;
}

.dropdown-divider {
    height: 1px;
    background: #e5e7eb;
    border: none;
    margin: 6px 0;
}

/* Hierarchy Panel */
.hierarchy-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 24px;
    height: fit-content;
    max-height: 80vh;
    overflow-y: auto;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.hierarchy-title {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.panel-actions {
    display: flex;
    gap: 4px;
}

.hierarchy-content {
    max-height: 60vh;
    overflow-y: auto;
    margin-bottom: 16px;
}

/* Tree Styles */
.tree-item {
    margin-bottom: 2px;
}

.tree-node {
    display: flex;
    align-items: center;
    padding: 8px 4px;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.tree-node:hover {
    background: #f8fafc;
}

.tree-node.selected {
    background: #eff6ff;
    border-left: 3px solid #3b82f6;
}

.tree-node.inactive {
    opacity: 0.6;
}

.tree-indent {
    height: 1px;
    flex-shrink: 0;
}

.tree-toggle {
    width: 16px;
    height: 16px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    transition: all 0.2s ease;
    margin-right: 4px;
}

.tree-toggle:hover {
    background: #e5e7eb;
}

.tree-toggle i {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.tree-toggle[data-expanded="false"] i {
    transform: rotate(-90deg);
}

.tree-spacer {
    width: 24px;
    height: 16px;
}

.tree-icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
    flex-shrink: 0;
    margin-right: 8px;
}

.tree-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.tree-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-count {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 400;
}

.tree-inactive-badge {
    padding: 1px 4px;
    background: #fecaca;
    color: #991b1b;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 500;
}

.tree-actions {
    display: none;
    gap: 2px;
}

.tree-node:hover .tree-actions {
    display: flex;
}

.tree-action-btn {
    width: 20px;
    height: 20px;
    border: none;
    background: #f1f5f9;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.tree-action-btn:hover {
    background: #e2e8f0;
}

.tree-children {
    border-left: 1px solid #e2e8f0;
    margin-left: 12px;
    padding-left: 8px;
    transition: all 0.3s ease;
}

.tree-children.collapsed {
    display: none;
}

/* Hierarchy Stats */
.hierarchy-stats {
    border-top: 1px solid #f1f5f9;
    padding-top: 16px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
}

.stat-row:last-child {
    margin-bottom: 0;
}

/* Empty States */
.empty-state,
.empty-hierarchy {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.empty-state i,
.empty-hierarchy i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #64748b;
}

.empty-state p {
    margin-bottom: 20px;
}

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

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.modal-content {
    background: white;
    padding: 0;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}

.modal-content.modal-sm {
    max-width: 400px;
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 0 24px;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #f1f5f9;
    color: #475569;
}

.modal-body {
    padding: 0 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 24px;
    border-top: 1px solid #f1f5f9;
    background: #fafbfc;
    margin-top: 24px;
}

/* Form Styles */
.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.form-group {
    flex: 1;
}

.form-group.full-width {
    flex: none;
    width: 100%;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: #374151;
}

.required {
    color: #ef4444;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'><path fill='%23666' d='M2 0L0 2h4zm0 5L0 3h4z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 40px;
    cursor: pointer;
}

.form-help {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

/* Special Form Inputs */
.icon-input-group {
    display: flex;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    overflow: hidden;
}

.icon-input-group .form-input {
    border: none;
    border-radius: 0;
    flex: 1;
}

.icon-input-group .form-input:focus {
    box-shadow: none;
}

.icon-input-group:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.icon-picker-btn {
    padding: 0 12px;
    border: none;
    background: #f9fafb;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-picker-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.icon-preview {
    margin-top: 8px;
    width: 32px;
    height: 32px;
    background: #6366f1;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.color-input {
    width: 60px;
    height: 42px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
}

.color-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.color-preset-buttons {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.color-preset {
    width: 20px;
    height: 20px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.color-preset:hover {
    transform: scale(1.1);
}

/* Checkbox Styles */
.form-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.form-checkbox {
    opacity: 0;
    position: absolute;
    pointer-events: none;
}

.form-checkbox-custom {
    width: 18px;
    height: 18px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-top: 2px;
}

.form-checkbox:checked + .form-checkbox-custom {
    background: #6366f1;
    border-color: #6366f1;
}

.form-checkbox:checked + .form-checkbox-custom::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Radio Styles */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.radio-label:hover {
    border-color: #6366f1;
    background: #f8fafc;
}

.radio-label input[type="radio"] {
    opacity: 0;
    position: absolute;
    pointer-events: none;
}

.radio-custom {
    width: 18px;
    height: 18px;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-top: 2px;
}

input[type="radio"]:checked + .radio-custom {
    border-color: #6366f1;
}

input[type="radio"]:checked + .radio-custom::after {
    content: '';
    width: 8px;
    height: 8px;
    background: #6366f1;
    border-radius: 50%;
}

.radio-content {
    flex: 1;
}

.radio-content strong {
    display: block;
    margin-bottom: 4px;
    color: #374151;
}

.radio-content p {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

/* Preview Styles */
.form-preview {
    margin-top: 20px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.preview-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
}

.preview-category-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.preview-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.preview-info {
    flex: 1;
}

.preview-name {
    font-weight: 500;
    color: #374151;
    margin-bottom: 2px;
}

.preview-path {
    font-size: 12px;
    color: #6b7280;
}

/* Delete Modal Specific Styles */
.delete-info {
    margin-bottom: 20px;
}

.category-to-delete {
    padding: 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    margin-bottom: 16px;
}

.delete-warning {
    margin-bottom: 16px;
}

.delete-warning p {
    margin-bottom: 8px;
}

.delete-consequences {
    padding: 12px;
    background: #fffbeb;
    border: 1px solid #fed7aa;
    border-radius: 6px;
    font-size: 13px;
    color: #92400e;
}

.confirmation-input {
    margin-top: 16px;
}

/* Pagination Styles */
.pagination-wrapper {
    border-top: 1px solid #f1f5f9;
    padding: 16px 20px;
}

.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.pagination-info {
    font-size: 13px;
    color: #64748b;
}

.pagination-list {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
}

.pagination-item {
    display: flex;
}

.pagination-link {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    background: white;
    color: #374151;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.2s ease;
}

.pagination-link:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.pagination-item.active .pagination-link {
    background: #6366f1;
    color: white;
    border-color: #6366f1;
}

.pagination-item.disabled .pagination-link {
    color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.5;
}

.pagination-jump {
    display: flex;
    gap: 16px;
    align-items: center;
}

.jump-to-page,
.per-page-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.jump-to-page input,
.per-page-selector select {
    width: 60px;
    padding: 4px 6px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
}

/* Loading Spinner */
.loading {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1001;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f4f6;
    border-top: 3px solid #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Alert Styles */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fecaca;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fed7aa;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Utility Classes */
.text-danger {
    color: #dc2626;
}

.text-success {
    color: #16a34a;
}

.text-warning {
    color: #ca8a04;
}

.text-info {
    color: #2563eb;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .header {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }

    .filters {
        flex-direction: column;
    }

    .filter-input {
        min-width: auto;
    }

    .category-item {
        padding: 16px 12px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .category-actions {
        order: -1;
        width: 100%;
        justify-content: flex-end;
    }

    .form-row {
        flex-direction: column;
    }

    .modal-content {
        width: 95%;
        margin: 20px;
    }

    .pagination-container {
        flex-direction: column;
        text-align: center;
    }
}
