/* ============================================
   COMPONENTS.CSS - Компоненты интерфейса
   Premium iOS Glass Design
   ============================================ */

/* ========== BUTTONS - PREMIUM DESIGN ========== */

.btn,
.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger,
.btn-warning,
.btn-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 11px 20px;
    font-family: var(--font-system);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.btn:disabled,
.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Primary Button - iOS Blue */
.btn-primary {
    background: linear-gradient(135deg, #007AFF 0%, #0051D5 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(0, 122, 255, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.2s;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0051D5 0%, #003DA5 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.4);
}

.btn-primary:hover::before {
    opacity: 1;
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

/* Secondary Button - Glass Effect */
.btn-secondary {
    background: rgba(142, 142, 147, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: var(--text-primary);
    border: 1px solid rgba(142, 142, 147, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.btn-secondary:hover {
    background: rgba(142, 142, 147, 0.25);
    border-color: rgba(142, 142, 147, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* Success Button - Green */
.btn-success {
    background: linear-gradient(135deg, #34C759 0%, #2AB04E 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(52, 199, 89, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-success:hover {
    background: linear-gradient(135deg, #2AB04E 0%, #1F9A3E 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 199, 89, 0.4);
}

.btn-success:active {
    transform: translateY(0);
}

/* Danger Button - Red */
.btn-danger {
    background: linear-gradient(135deg, #FF3B30 0%, #E62E23 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(255, 59, 48, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #E62E23 0%, #CC1F17 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 59, 48, 0.4);
}

.btn-danger:active {
    transform: translateY(0);
}

/* Warning Button - Orange */
.btn-warning {
    background: linear-gradient(135deg, #FF9500 0%, #E68800 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(255, 149, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-warning:hover {
    background: linear-gradient(135deg, #E68800 0%, #CC7600 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 149, 0, 0.4);
}

.btn-warning:active {
    transform: translateY(0);
}

/* Info Button - Teal */
.btn-info {
    background: linear-gradient(135deg, #5AC8FA 0%, #4AB8E8 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(90, 200, 250, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-info:hover {
    background: linear-gradient(135deg, #4AB8E8 0%, #3AA8D8 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(90, 200, 250, 0.4);
}

.btn-info:active {
    transform: translateY(0);
}

/* Button Sizes */
.btn-small {
    padding: 8px 14px;
    font-size: 13px;
    border-radius: 8px;
}

.btn-large {
    padding: 14px 28px;
    font-size: 16px;
    border-radius: 12px;
}

/* Button Close */
.btn-close {
    background: rgba(142, 142, 147, 0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-secondary);
    border: none;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-close:hover {
    background: rgba(142, 142, 147, 0.2);
    color: var(--text-primary);
    transform: rotate(90deg);
}

/* Icon Button */
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
}

.btn-icon.btn-small {
    width: 30px;
    height: 30px;
}

/* ========== BADGES - IMPROVED ========== */

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 12px;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.badge-mini {
    padding: 3px 8px;
    font-size: 11px;
}

.badge.success {
    background: rgba(52, 199, 89, 0.15);
    color: #2AB04E;
    border: 1px solid rgba(52, 199, 89, 0.2);
}

.badge.danger {
    background: rgba(255, 59, 48, 0.15);
    color: #E62E23;
    border: 1px solid rgba(255, 59, 48, 0.2);
}

.badge.warning {
    background: rgba(255, 149, 0, 0.15);
    color: #E68800;
    border: 1px solid rgba(255, 149, 0, 0.2);
}

.badge.info {
    background: rgba(0, 122, 255, 0.15);
    color: #0051D5;
    border: 1px solid rgba(0, 122, 255, 0.2);
}

.badge.primary {
    background: linear-gradient(135deg, #007AFF 0%, #0051D5 100%);
    color: white;
    border: none;
}

.badge.secondary {
    background: rgba(142, 142, 147, 0.12);
    color: var(--text-secondary);
    border: 1px solid rgba(142, 142, 147, 0.15);
}

/* ========== TABLES - MODERN DESIGN ========== */

.ios-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

.ios-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: transparent;
}

.ios-table tbody tr {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ios-table tbody td {
    padding: 16px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ios-table tbody td:first-child {
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
    padding-left: 20px;
}

.ios-table tbody td:last-child {
    border-right: 1px solid rgba(255, 255, 255, 0.3);
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
    padding-right: 20px;
}

.ios-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.9);
    border-top-color: rgba(0, 122, 255, 0.2);
    border-bottom-color: rgba(0, 122, 255, 0.2);
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.1);
}

.ios-table tbody tr:hover td:first-child {
    border-left-color: rgba(0, 122, 255, 0.2);
}

.ios-table tbody tr:hover td:last-child {
    border-right-color: rgba(0, 122, 255, 0.2);
}

.ios-table tbody tr:hover {
    transform: translateX(4px);
}

/* ========== MODALS - PREMIUM ========== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1040;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    animation: modalFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.9) translateY(30px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.modal-large {
    max-width: 900px;
}

.modal-small {
    max-width: 400px;
}

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

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

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

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 320px;
    max-width: 420px;
    pointer-events: auto;
    animation: toastSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes toastSlideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 4px solid #34C759;
}

.toast.error {
    border-left: 4px solid #FF3B30;
}

.toast.warning {
    border-left: 4px solid #FF9500;
}

.toast.info {
    border-left: 4px solid #007AFF;
}

.toast i {
    font-size: 20px;
    flex-shrink: 0;
}

.toast.success i { color: #34C759; }
.toast.error i { color: #FF3B30; }
.toast.warning i { color: #FF9500; }
.toast.info i { color: #007AFF; }

/* ========== LOADING STATES ========== */

.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.loading i {
    font-size: 36px;
    animation: spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    color: var(--ios-blue);
}

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

.loading-small {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 13px;
}

.loading-small i {
    margin-right: 8px;
    color: var(--ios-blue);
}

/* ========== STATISTICS ========== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-icon.blue { 
    background: linear-gradient(135deg, #007AFF 0%, #0051D5 100%);
}
.stat-icon.green { 
    background: linear-gradient(135deg, #34C759 0%, #2AB04E 100%);
}
.stat-icon.orange { 
    background: linear-gradient(135deg, #FF9500 0%, #E68800 100%);
}
.stat-icon.purple { 
    background: linear-gradient(135deg, #AF52DE 0%, #8E3CC4 100%);
}
.stat-icon.red { 
    background: linear-gradient(135deg, #FF3B30 0%, #E62E23 100%);
}
.stat-icon.teal { 
    background: linear-gradient(135deg, #5AC8FA 0%, #4AB8E8 100%);
}

.stat-content h3 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.stat-content p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ========== EMPTY STATES ========== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    background: rgba(142, 142, 147, 0.06);
    border-radius: 12px;
}

/* ========== STATUS INDICATOR ========== */

.status-indicator {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 12px;
    background: rgba(142, 142, 147, 0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.status-indicator i {
    font-size: 10px;
    margin-right: 6px;
}

.status-indicator.active {
    background: rgba(52, 199, 89, 0.15);
}

.status-indicator.active i {
    color: #34C759;
}

.status-indicator.inactive {
    background: rgba(255, 59, 48, 0.15);
}

.status-indicator.inactive i {
    color: #FF3B30;
}

.status-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    background: rgba(142, 142, 147, 0.06);
    border-radius: 10px;
}

.status-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 14px;
}

.status-value {
    font-weight: 600;
    font-size: 14px;
}

.status-value.success {
    color: #34C759;
}

.status-value.error {
    color: #FF3B30;
}

/* ========== QUICK ACTIONS ========== */

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.action-btn {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

.action-btn:hover {
    background: linear-gradient(135deg, #007AFF 0%, #0051D5 100%);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 122, 255, 0.3);
}

.action-btn i {
    font-size: 24px;
}

.action-btn span {
    font-size: 13px;
    font-weight: 500;
}

/* ========== PROTOCOLS LIST ========== */

.protocols-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.protocol-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: rgba(142, 142, 147, 0.06);
    border-radius: 10px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.protocol-item:hover {
    background: rgba(0, 122, 255, 0.08);
    border-color: rgba(0, 122, 255, 0.2);
    transform: translateX(4px);
}

.protocol-name {
    font-weight: 600;
    color: var(--ios-blue);
    font-size: 14px;
}

.protocol-count {
    background: linear-gradient(135deg, #007AFF 0%, #0051D5 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* ========== DARK MODE ========== */

@media (prefers-color-scheme: dark) {
    .ios-table tbody tr {
        background: rgba(44, 44, 46, 0.6);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .ios-table tbody tr:hover {
        background: rgba(44, 44, 46, 0.8);
    }
    
    .modal-content {
        background: rgba(28, 28, 30, 0.95);
        border-color: rgba(255, 255, 255, 0.15);
    }
    
    .toast {
        background: rgba(28, 28, 30, 0.95);
        border-color: rgba(255, 255, 255, 0.15);
    }
    
    .action-btn {
        background: rgba(44, 44, 46, 0.6);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .btn-secondary {
        background: rgba(142, 142, 147, 0.25);
        color: white;
    }
}

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

@media (max-width: 768px) {
    .modal-content {
        max-width: 100%;
        margin: 10px;
    }
    
    .toast-container {
        left: 12px;
        right: 12px;
    }
    
    .toast {
        min-width: auto;
        max-width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .quick-actions {
        grid-template-columns: 1fr;
    }
    
    .ios-table tbody tr:hover {
        transform: none;
    }
}

/* ========== ALERT MESSAGES ========== */

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.alert i {
    font-size: 18px;
    margin-top: 2px;
}

.alert-info {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 1px solid #90caf9;
    color: #1976d2;
}

.alert-success {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 1px solid #81c784;
    color: #388e3c;
}

.alert-warning {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border: 1px solid #ffb74d;
    color: #f57c00;
}

.alert-error {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    border: 1px solid #e57373;
    color: #d32f2f;
}