/**
 * ==========================================
 * KATEGOORIAHALDUSE CSS
 * ==========================================
 * Täielik stiilipakett kategooriate haldamiseks
 * Versioon: 2.0
 * ==========================================
 */

:root {
    --category-primary: #3B82F6;
    --category-primary-light: #DBEAFE;
    --category-primary-dark: #1E40AF;
    --category-success: #10B981;
    --category-success-light: #D1FAE5;
    --category-danger: #EF4444;
    --category-danger-light: #FEE2E2;
    --category-warning: #F59E0B;
    --category-warning-light: #FEF3C7;
    --category-gray-50: #F9FAFB;
    --category-gray-100: #F3F4F6;
    --category-gray-200: #E5E7EB;
    --category-gray-300: #D1D5DB;
    --category-gray-400: #9CA3AF;
    --category-gray-500: #6B7280;
    --category-gray-600: #4B5563;
    --category-gray-700: #374151;
    --category-gray-800: #1F2937;
    --category-gray-900: #111827;
    --category-white: #FFFFFF;
    
    --category-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --category-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --category-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --category-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --category-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    --category-radius: 8px;
    --category-radius-lg: 12px;
    --category-radius-xl: 16px;
    --category-radius-full: 9999px;
    
    --category-spacing-1: 4px;
    --category-spacing-2: 8px;
    --category-spacing-3: 12px;
    --category-spacing-4: 16px;
    --category-spacing-5: 20px;
    --category-spacing-6: 24px;
    --category-spacing-8: 32px;
    --category-spacing-10: 40px;
    --category-spacing-12: 48px;
    --category-spacing-16: 64px;
    
    --category-font-xs: 0.75rem;
    --category-font-sm: 0.875rem;
    --category-font-base: 1rem;
    --category-font-lg: 1.125rem;
    --category-font-xl: 1.25rem;
    --category-font-2xl: 1.5rem;
    --category-font-3xl: 1.875rem;
    
    --category-transition: all 0.2s ease-in-out;
}

/* ==========================================
   PÕHISTRUKTUUR
   ========================================== */

.category-manager {
    background: var(--category-white);
    border-radius: var(--category-radius-xl);
    box-shadow: var(--category-shadow);
    overflow: hidden;
    margin-bottom: var(--category-spacing-8);
}

.category-manager-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--category-spacing-6);
    background: linear-gradient(135deg, var(--category-primary), var(--category-primary-dark));
    color: var(--category-white);
}

.category-manager-header h2 {
    margin: 0;
    font-size: var(--category-font-2xl);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--category-spacing-3);
}

.category-manager-content {
    padding: var(--category-spacing-6);
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--category-spacing-6);
}

/* ==========================================
   KATEGOORIA KAARDID
   ========================================== */

.category-card {
    background: var(--category-white);
    border: 1px solid var(--category-gray-200);
    border-radius: var(--category-radius-lg);
    overflow: hidden;
    transition: var(--category-transition);
    position: relative;
}

.category-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--category-shadow-md);
    border-color: var(--category-primary);
}

.system-category {
    border-left: 4px solid var(--category-primary);
}

.user-category {
    border-left: 4px solid var(--category-success);
}

.category-card-header {
    display: flex;
    align-items: center;
    padding: var(--category-spacing-4);
    background: var(--category-gray-50);
    border-bottom: 1px solid var(--category-gray-200);
}

.category-visual {
    display: flex;
    align-items: center;
    gap: var(--category-spacing-2);
    margin-right: var(--category-spacing-4);
}

.category-icon {
    font-size: var(--category-font-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.category-color-dot {
    width: 16px;
    height: 16px;
    border-radius: var(--category-radius-full);
    border: 2px solid var(--category-white);
    box-shadow: var(--category-shadow-sm);
}

.category-info {
    flex: 1;
}

.category-name {
    margin: 0 0 var(--category-spacing-1) 0;
    font-size: var(--category-font-lg);
    font-weight: 600;
    color: var(--category-gray-900);
}

.category-meta {
    font-size: var(--category-font-sm);
    color: var(--category-gray-600);
    display: flex;
    align-items: center;
    gap: var(--category-spacing-2);
}

.category-actions {
    display: flex;
    gap: var(--category-spacing-2);
}

.category-card-body {
    padding: var(--category-spacing-4);
}

.category-settings {
    display: flex;
    flex-direction: column;
    gap: var(--category-spacing-3);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--category-spacing-3);
}

.setting-label {
    font-size: var(--category-font-sm);
    font-weight: 500;
    color: var(--category-gray-700);
    flex-shrink: 0;
}

.setting-value {
    font-size: var(--category-font-sm);
    color: var(--category-gray-600);
    text-align: right;
}

.custom-template {
    font-style: italic;
    background: var(--category-gray-100);
    padding: var(--category-spacing-2);
    border-radius: var(--category-radius);
    font-size: var(--category-font-xs);
    max-width: 200px;
    word-break: break-word;
}

/* ==========================================
   NUPUD
   ========================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--category-spacing-2);
    padding: var(--category-spacing-3) var(--category-spacing-4);
    border-radius: var(--category-radius);
    font-weight: 500;
    font-size: var(--category-font-sm);
    transition: var(--category-transition);
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    background: transparent;
    justify-content: center;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

.btn-primary:hover {
    background: var(--category-primary-dark);
    border-color: var(--category-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--category-shadow-md);
}

.btn-secondary {
    background: var(--category-gray-100);
    color: var(--category-gray-700);
    border-color: var(--category-gray-300);
}

.btn-secondary:hover {
    background: var(--category-gray-200);
    border-color: var(--category-gray-400);
}

.btn-outline {
    background: var(--category-white);
    color: var(--category-gray-700);
    border-color: var(--category-gray-300);
}

.btn-outline:hover {
    background: var(--category-gray-50);
    border-color: var(--category-primary);
    color: var(--category-primary);
}

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

.btn-danger:hover {
    background: #DC2626;
    border-color: #DC2626;
    transform: translateY(-1px);
}

.btn-sm {
    padding: var(--category-spacing-2) var(--category-spacing-3);
    font-size: var(--category-font-xs);
}

.btn-lg {
    padding: var(--category-spacing-4) var(--category-spacing-6);
    font-size: var(--category-font-lg);
}

/* ==========================================
   MODAL DIALOOGID
   ========================================== */

.category-modal .modal-content {
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--category-spacing-4);
    opacity: 0;
    animation: fadeIn 0.2s forwards;
}

.modal-content {
    background: var(--category-white);
    border-radius: var(--category-radius-xl);
    box-shadow: var(--category-shadow-xl);
    transform: scale(0.95);
    animation: scaleIn 0.2s forwards;
    border: 1px solid var(--category-gray-200);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--category-spacing-6);
    border-bottom: 1px solid var(--category-gray-200);
    background: var(--category-gray-50);
    border-radius: var(--category-radius-xl) var(--category-radius-xl) 0 0;
}

.modal-title {
    font-size: var(--category-font-xl);
    font-weight: 600;
    color: var(--category-gray-900);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--category-gray-500);
    padding: var(--category-spacing-2);
    border-radius: var(--category-radius);
    transition: var(--category-transition);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--category-gray-100);
    color: var(--category-gray-700);
}

.modal-body {
    padding: var(--category-spacing-6);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--category-spacing-3);
    padding: var(--category-spacing-6);
    border-top: 1px solid var(--category-gray-200);
    background: var(--category-gray-50);
    border-radius: 0 0 var(--category-radius-xl) var(--category-radius-xl);
}

/* ==========================================
   VORMIELEMENDID
   ========================================== */

.form-section {
    margin-bottom: var(--category-spacing-8);
    padding-bottom: var(--category-spacing-6);
    border-bottom: 1px solid var(--category-gray-200);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section h3 {
    font-size: var(--category-font-lg);
    font-weight: 600;
    color: var(--category-gray-900);
    margin: 0 0 var(--category-spacing-4) 0;
    display: flex;
    align-items: center;
    gap: var(--category-spacing-2);
}

.form-group {
    margin-bottom: var(--category-spacing-4);
}

.form-group label {
    display: block;
    margin-bottom: var(--category-spacing-2);
    font-weight: 500;
    color: var(--category-gray-700);
    font-size: var(--category-font-sm);
}

.required {
    color: var(--category-danger);
}

.form-control {
    width: 100%;
    padding: var(--category-spacing-3);
    border: 1px solid var(--category-gray-300);
    border-radius: var(--category-radius);
    font-size: var(--category-font-sm);
    background: var(--category-white);
    transition: var(--category-transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--category-primary);
    box-shadow: 0 0 0 3px var(--category-primary-light);
}

.form-control::placeholder {
    color: var(--category-gray-400);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--category-spacing-4);
}

.form-hint {
    display: block;
    font-size: var(--category-font-xs);
    color: var(--category-gray-500);
    margin-top: var(--category-spacing-2);
    font-style: italic;
}

/* ==========================================
   CHECKBOX JA SELECTID
   ========================================== */

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--category-spacing-3);
    cursor: pointer;
    font-weight: 500;
    color: var(--category-gray-700);
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--category-gray-300);
    border-radius: var(--category-radius);
    background: var(--category-white);
    position: relative;
    transition: var(--category-transition);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--category-primary);
    border-color: var(--category-primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--category-white);
    font-size: var(--category-font-xs);
    font-weight: bold;
}

.reminder-settings {
    margin-left: var(--category-spacing-6);
    padding: var(--category-spacing-4);
    background: var(--category-gray-50);
    border-radius: var(--category-radius);
    border: 1px solid var(--category-gray-200);
}

/* ==========================================
   IKOONIDE JA VÄRVIDE VALIJAD
   ========================================== */

.icon-selector,
.color-selector {
    position: relative;
}

.icon-selector-btn,
.color-selector-btn {
    display: flex;
    align-items: center;
    gap: var(--category-spacing-3);
    padding: var(--category-spacing-3);
    border: 1px solid var(--category-gray-300);
    border-radius: var(--category-radius);
    background: var(--category-white);
    cursor: pointer;
    transition: var(--category-transition);
    width: 100%;
    font-size: var(--category-font-sm);
}

.icon-selector-btn:hover,
.color-selector-btn:hover {
    border-color: var(--category-primary);
    box-shadow: 0 0 0 3px var(--category-primary-light);
}

.color-preview {
    width: 20px;
    height: 20px;
    border-radius: var(--category-radius);
    border: 2px solid var(--category-white);
    box-shadow: var(--category-shadow-sm);
}

.icon-picker-modal .modal-content,
.color-picker-modal .modal-content {
    max-width: 500px;
}

.icon-grid,
.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: var(--category-spacing-2);
    max-height: 400px;
    overflow-y: auto;
}

.icon-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--category-spacing-3);
    border: 1px solid var(--category-gray-200);
    border-radius: var(--category-radius);
    background: var(--category-white);
    cursor: pointer;
    transition: var(--category-transition);
    font-size: var(--category-font-lg);
    height: 60px;
}

.icon-option:hover {
    border-color: var(--category-primary);
    background: var(--category-primary-light);
    transform: scale(1.05);
}

.color-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.color-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--category-spacing-2);
    padding: var(--category-spacing-3);
    border: 1px solid var(--category-gray-200);
    border-radius: var(--category-radius);
    background: var(--category-white);
    cursor: pointer;
    transition: var(--category-transition);
}

.color-option:hover {
    border-color: var(--category-primary);
    background: var(--category-primary-light);
    transform: translateY(-2px);
}

.color-sample {
    width: 32px;
    height: 32px;
    border-radius: var(--category-radius);
    border: 2px solid var(--category-white);
    box-shadow: var(--category-shadow);
}

.color-name {
    font-size: var(--category-font-xs);
    color: var(--category-gray-600);
    text-align: center;
}

/* ==========================================
   MALLIDE SOOVITUSED
   ========================================== */

.template-suggestions {
    margin-top: var(--category-spacing-4);
    padding: var(--category-spacing-4);
    background: var(--category-white);
    border: 1px solid var(--category-gray-200);
    border-radius: var(--category-radius);
}

.suggestions-header {
    font-size: var(--category-font-sm);
    font-weight: 600;
    color: var(--category-gray-700);
    margin-bottom: var(--category-spacing-3);
}

.suggestions-list {
    display: flex;
    flex-direction: column;
    gap: var(--category-spacing-2);
}

.template-suggestion {
    padding: var(--category-spacing-2) var(--category-spacing-3);
    border: 1px solid var(--category-gray-200);
    border-radius: var(--category-radius);
    background: var(--category-gray-50);
    cursor: pointer;
    transition: var(--category-transition);
    font-size: var(--category-font-sm);
    text-align: left;
    color: var(--category-gray-700);
}

.template-suggestion:hover {
    border-color: var(--category-primary);
    background: var(--category-primary-light);
    color: var(--category-primary-dark);
}

/* ==========================================
   TOAST NOTIFICATIONS
   ========================================== */

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--category-white);
    border-radius: var(--category-radius-lg);
    padding: var(--category-spacing-4);
    box-shadow: var(--category-shadow-lg);
    z-index: 2000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    max-width: 400px;
    border-left: 4px solid var(--category-gray-300);
    display: flex;
    align-items: center;
    gap: var(--category-spacing-3);
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    border-left-color: var(--category-success);
    background: var(--category-success-light);
}

.toast-error {
    border-left-color: var(--category-danger);
    background: var(--category-danger-light);
}

.toast-warning {
    border-left-color: var(--category-warning);
    background: var(--category-warning-light);
}

.toast-icon {
    font-size: var(--category-font-lg);
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: var(--category-font-sm);
    font-weight: 500;
}

/* ==========================================
   ANIMATSIOONID
   ========================================== */

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

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 768px) {
    .categories-grid {
        grid-template-columns: 1fr;
    }
    
    .category-manager-header {
        flex-direction: column;
        gap: var(--category-spacing-4);
        text-align: center;
    }
    
    .modal-content {
        width: 95%;
        margin: var(--category-spacing-4);
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .icon-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }
    
    .color-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .category-actions {
        margin-top: var(--category-spacing-2);
    }
    
    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--category-spacing-1);
    }
    
    .setting-value {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .category-manager-header h2 {
        font-size: var(--category-font-xl);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--category-spacing-4);
    }
    
    .category-card-header,
    .category-card-body {
        padding: var(--category-spacing-3);
    }
    
    .toast {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
    .category-manager-header .btn,
    .category-actions,
    .modal-overlay,
    .toast {
        display: none !important;
    }
    
    .category-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--category-gray-300);
    }
}