/**
 * IPTECNOCONTROL - Admin Panel Styles
 */

/* Hide elements with x-cloak until Alpine is ready */
[x-cloak] {
    display: none !important;
}

/* Custom scrollbar for sidebar */
aside::-webkit-scrollbar {
    width: 6px;
}

aside::-webkit-scrollbar-track {
    background: transparent;
}

aside::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

aside::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Main content scrollbar */
main::-webkit-scrollbar {
    width: 8px;
}

main::-webkit-scrollbar-track {
    background: #f1f5f9;
}

main::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

main::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Transitions for sections */
.section-enter {
    opacity: 0;
    transform: translateY(10px);
}

.section-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: all 0.2s ease-out;
}

/* Card hover effects */
.module-card {
    transition: all 0.2s ease;
}

.module-card:hover {
    transform: translateY(-2px);
}

/* Table styles */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    font-weight: 600;
    color: #475569;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
}

.data-table tr:hover td {
    background: #f8fafc;
}

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-gray {
    background: #f1f5f9;
    color: #475569;
}

.badge-purple {
    background: #f3e8ff;
    color: #7c3aed;
}

/* Form styles */
.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

/* Button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease-in-out;
    cursor: pointer;
    border: 1px solid transparent;
    outline: none;
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3), 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: white;
    color: #475569;
    border-color: #e2e8f0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.btn-secondary:active:not(:disabled) {
    background: #f1f5f9;
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    box-shadow: 0 1px 3px rgba(220, 38, 38, 0.3), 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
    box-shadow: 0 4px 6px rgba(220, 38, 38, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #047857 0%, #065f46 100%);
    color: white;
    box-shadow: 0 1px 3px rgba(4, 120, 87, 0.3), 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-success:hover:not(:disabled) {
    background: linear-gradient(135deg, #065f46 0%, #064e3b 100%);
    box-shadow: 0 4px 6px rgba(4, 120, 87, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #451a03;
    box-shadow: 0 1px 3px rgba(245, 158, 11, 0.3), 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-warning:hover:not(:disabled) {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    box-shadow: 0 4px 6px rgba(245, 158, 11, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    gap: 0.375rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* Loading spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #64748b;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    opacity: 0.5;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.pagination button.active {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal styles */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 24px;
}

.tab {
    padding: 12px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    color: #334155;
}

.tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    background: white;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    animation: toastSlideIn 0.3s ease;
    border-left: 4px solid;
}

.toast.toast-success {
    border-left-color: #22c55e;
}

.toast.toast-error {
    border-left-color: #ef4444;
}

.toast.toast-warning {
    border-left-color: #f59e0b;
}

.toast.toast-info {
    border-left-color: #3b82f6;
}

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.toast-success .toast-icon {
    color: #22c55e;
}

.toast-error .toast-icon {
    color: #ef4444;
}

.toast-warning .toast-icon {
    color: #f59e0b;
}

.toast-info .toast-icon {
    color: #3b82f6;
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: #1f2937;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.8125rem;
    color: #6b7280;
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.toast-close:hover {
    background: #f3f4f6;
    color: #6b7280;
}

.toast.toast-exit {
    animation: toastSlideOut 0.3s ease forwards;
}

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

@keyframes toastSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    aside {
        width: 200px;
    }
    main {
        margin-left: 200px;
    }
}

@media (max-width: 768px) {
    aside {
        position: fixed;
        left: -256px;
        transition: left 0.3s ease;
        z-index: 40;
    }
    aside.open {
        left: 0;
    }
    main {
        margin-left: 0;
    }
}

/* Geofence pulse highlight (D1) */
@keyframes geofence-ring-pulse {
    0%, 100% { opacity: 0.8; stroke-width: 3; }
    50% { opacity: 0.3; stroke-width: 1; }
}
.geofence-pulse {
    animation: geofence-ring-pulse 1.5s ease-in-out infinite;
}
