/* Cartographer Component Library
 * Reusable UI components with Forerunner aesthetic
 * Used across all pages for consistent styling
 */

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 10px 20px;
    border: none;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--font-primary);
    letter-spacing: 1px;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;

    /* Angular shape */
    clip-path: polygon(
            4px 0,
            100% 0,
            100% calc(100% - 4px),
            calc(100% - 4px) 100%,
            0 100%,
            0 4px
    );
}

/* Scan-line effect on buttons */
.btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
            to bottom,
            transparent 0%,
            rgba(255, 255, 255, 0.1) 50%,
            transparent 100%
    );
    transform: translateY(-100%);
    transition: transform 0.6s ease;
}

.btn:hover::before {
    transform: translateY(100%);
}

.btn-primary {
    background: linear-gradient(135deg, var(--cyan-medium), var(--cyan-dark));
    color: var(--text-primary);
    border: 1px solid var(--cyan-bright);
    box-shadow:
            0 0 15px var(--cyan-glow),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--cyan-bright), var(--cyan-medium));
    box-shadow:
            0 0 25px var(--cyan-glow),
            0 0 40px rgba(0, 229, 255, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    border-color: var(--cyan-medium);
    box-shadow:
            0 0 15px rgba(0, 180, 212, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.btn-ghost:hover {
    color: var(--cyan-bright);
    border-color: var(--border-subtle);
    background: rgba(0, 180, 212, 0.1);
    text-shadow: 0 0 10px var(--cyan-glow);
}

.btn-danger {
    background: linear-gradient(135deg, var(--error), #cc3200);
    color: var(--text-primary);
    border: 1px solid var(--error);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #ff5722, var(--error));
    box-shadow: 0 0 20px rgba(255, 61, 0, 0.4);
}

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

.btn-sm {
    padding: 6px 14px;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

/* ============================================
   PANELS
   ============================================ */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-medium);
    backdrop-filter: blur(8px);
    position: relative;
    overflow: hidden;

    /* Angular clip */
    clip-path: polygon(
            8px 0,
            calc(100% - 8px) 0,
            100% 8px,
            100% calc(100% - 8px),
            calc(100% - 8px) 100%,
            8px 100%,
            0 calc(100% - 8px),
            0 8px
    );

    box-shadow:
            0 4px 25px rgba(0, 0, 0, 0.4),
            inset 0 1px 0 rgba(0, 229, 255, 0.1);
}

.panel-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.1), transparent);
    border-bottom: 1px solid var(--border-medium);
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--cyan-bright);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2,
.panel-header h3 {
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
}

.panel-content {
    padding: 20px;
}

.panel-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-medium);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

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

/* Panel variants */
.panel-info {
    border-color: var(--cyan-medium);
    box-shadow:
            0 4px 25px rgba(0, 229, 255, 0.15),
            inset 0 1px 0 rgba(0, 229, 255, 0.2);
}

.panel-warning {
    border-color: var(--warning);
    box-shadow:
            0 4px 25px rgba(255, 196, 0, 0.15),
            inset 0 1px 0 rgba(255, 196, 0, 0.2);
}

.panel-error {
    border-color: var(--error);
    box-shadow:
            0 4px 25px rgba(255, 61, 0, 0.15),
            inset 0 1px 0 rgba(255, 61, 0, 0.2);
}

/* ============================================
   STATUS BADGES
   ============================================ */
.status-badge {
    padding: 4px 10px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-badge.unlocked,
.status-badge.healthy {
    color: var(--success);
    background: rgba(0, 230, 118, 0.15);
    border: 1px solid var(--success);
    box-shadow: 0 0 8px rgba(0, 230, 118, 0.3);
}

.status-badge.locked,
.status-badge.unhealthy {
    color: var(--error);
    background: rgba(255, 61, 0, 0.15);
    border: 1px solid var(--error);
    box-shadow: 0 0 8px rgba(255, 61, 0, 0.3);
    animation: statusPulse 2s ease-in-out infinite;
}

.status-badge.warning,
.status-badge.degraded {
    color: var(--warning);
    background: rgba(255, 196, 0, 0.15);
    border: 1px solid var(--warning);
    box-shadow: 0 0 8px rgba(255, 196, 0, 0.3);
}

.status-badge.info {
    color: var(--cyan-bright);
    background: rgba(0, 229, 255, 0.15);
    border: 1px solid var(--cyan-medium);
    box-shadow: 0 0 8px var(--cyan-glow);
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ============================================
   METRIC CARDS
   ============================================ */
.metric-card {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-medium);
    padding: 16px;
    text-align: center;
    position: relative;

    clip-path: polygon(
            6px 0,
            calc(100% - 6px) 0,
            100% 6px,
            100% calc(100% - 6px),
            calc(100% - 6px) 100%,
            6px 100%,
            0 calc(100% - 6px),
            0 6px
    );
}

.metric-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-family: var(--font-primary);
    margin-bottom: 8px;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--cyan-bright);
    text-shadow: 0 0 10px var(--cyan-glow);
}

.metric-value.metric-success {
    color: var(--success);
    text-shadow: 0 0 10px rgba(0, 230, 118, 0.4);
}

.metric-value.metric-warning {
    color: var(--warning);
    text-shadow: 0 0 10px rgba(255, 196, 0, 0.4);
}

.metric-value.metric-error {
    color: var(--error);
    text-shadow: 0 0 10px rgba(255, 61, 0, 0.4);
}

/* ============================================
   NAVIGATION SIDEBAR
   ============================================ */
.nav-sidebar {
    width: 280px;
    background: linear-gradient(
            180deg,
            rgba(20, 35, 50, 0.95) 0%,
            rgba(10, 20, 35, 0.98) 100%
    );
    border-right: 2px solid var(--cyan-medium);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    height: 100%;

    /* Hexagonal pattern overlay */
    background-image:
            linear-gradient(
                    180deg,
                    rgba(20, 35, 50, 0.95) 0%,
                    rgba(10, 20, 35, 0.98) 100%
            ),
            repeating-linear-gradient(
                    60deg,
                    transparent,
                    transparent 40px,
                    rgba(0, 180, 212, 0.03) 40px,
                    rgba(0, 180, 212, 0.03) 42px
            );

    box-shadow:
            inset -2px 0 20px rgba(0, 229, 255, 0.1),
            2px 0 30px rgba(0, 0, 0, 0.5);
}

/* Animated side glow */
.nav-sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(
            180deg,
            transparent 0%,
            var(--cyan-bright) 50%,
            transparent 100%
    );
    animation: sidebarGlow 3s ease-in-out infinite;
    z-index: 1;
}

@keyframes sidebarGlow {
    0%, 100% { transform: translateY(-50%); }
    50% { transform: translateY(50%); }
}

.nav-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-medium);
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.1), transparent);
}

.nav-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    background: rgba(20, 35, 50, 0.3);
    border: 1px solid transparent;
    text-decoration: none;
    color: var(--text-secondary);

    clip-path: polygon(
            0 0,
            100% 0,
            100% calc(100% - 6px),
            calc(100% - 6px) 100%,
            0 100%
    );
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: var(--cyan-medium);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.nav-item:hover {
    background: rgba(0, 180, 212, 0.15);
    border-color: var(--border-subtle);
    transform: translateX(4px);
    color: var(--text-primary);
}

.nav-item:hover::before {
    transform: scaleY(1);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(0, 229, 255, 0.2), rgba(0, 180, 212, 0.1));
    border-color: var(--cyan-medium);
    box-shadow:
            0 0 15px rgba(0, 229, 255, 0.2),
            inset 0 0 20px rgba(0, 229, 255, 0.05);
    color: var(--cyan-bright);
}

.nav-item.active::before {
    transform: scaleY(1);
    box-shadow: 0 0 10px var(--cyan-bright);
}

.nav-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.nav-label {
    font-size: 0.875rem;
    font-family: var(--font-primary);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.nav-footer {
    padding: 16px;
    border-top: 1px solid var(--border-medium);
    background: rgba(0, 0, 0, 0.3);
}

.nav-user-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-user-email {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    word-break: break-all;
}

.nav-lock-status {
    margin-top: 12px;
}

/* ============================================
   MODAL OVERLAYS
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: modalFadeIn 0.3s ease;
    backdrop-filter: blur(4px);
}

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

.modal {
    max-width: 500px;
    width: 90%;
    background: var(--bg-secondary);
    border: 2px solid var(--cyan-medium);
    box-shadow: 0 0 40px var(--cyan-glow);
    animation: modalSlideUp 0.3s ease;
    position: relative;
}

@keyframes modalSlideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-medium);
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.1), transparent);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-family: var(--font-primary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--cyan-bright);
}

.modal-content {
    padding: 24px;
}

.modal-actions {
    padding: 16px 20px;
    border-top: 1px solid var(--border-medium);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ============================================
   LOADING INDICATORS
   ============================================ */
.spinner {
    width: 40px;
    height: 40px;
    position: relative;
    margin: 0 auto;
}

.spinner::before {
    content: '';
    width: 100%;
    height: 100%;
    border: 3px solid var(--border-medium);
    border-top-color: var(--cyan-bright);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: absolute;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
}

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

.thinking-dots {
    display: flex;
    gap: 6px;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    background: var(--cyan-bright);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    animation: thinkingPulse 1.4s infinite ease-in-out;
    box-shadow: 0 0 10px var(--cyan-bright);
}

.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkingPulse {
    0%, 80%, 100% {
        transform: scale(0.8) rotate(0deg);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2) rotate(45deg);
        opacity: 1;
    }
}

/* ============================================
   DATA TABLES
   ============================================ */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-medium);
    overflow: hidden;

    clip-path: polygon(
            6px 0,
            calc(100% - 6px) 0,
            100% 6px,
            100% calc(100% - 6px),
            calc(100% - 6px) 100%,
            6px 100%,
            0 calc(100% - 6px),
            0 6px
    );
}

.data-table thead {
    background: linear-gradient(
            135deg,
            rgba(0, 180, 212, 0.3),
            rgba(0, 180, 212, 0.15)
    );
}

.data-table th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 700;
    border-bottom: 2px solid var(--cyan-medium);
    color: var(--cyan-bright);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.75rem;
    font-family: var(--font-primary);
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: rgba(0, 180, 212, 0.08);
    color: var(--text-primary);
}

.data-table td:first-child {
    border-left: 2px solid transparent;
}

.data-table tbody tr:hover td:first-child {
    border-left-color: var(--cyan-medium);
}

/* ============================================
   PROGRESS BARS
   ============================================ */
.progress {
    height: 8px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-medium);
    position: relative;
    overflow: hidden;
    clip-path: polygon(
            3px 0,
            calc(100% - 3px) 0,
            100% 3px,
            100% calc(100% - 3px),
            calc(100% - 3px) 100%,
            3px 100%,
            0 calc(100% - 3px),
            0 3px
    );
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--cyan-dark), var(--cyan-bright));
    box-shadow: 0 0 10px var(--cyan-glow);
    transition: width 0.3s ease;
}

.progress-bar.progress-success {
    background: linear-gradient(90deg, #00c853, var(--success));
}

.progress-bar.progress-warning {
    background: linear-gradient(90deg, #ffb300, var(--warning));
}

.progress-bar.progress-error {
    background: linear-gradient(90deg, #d32f2f, var(--error));
}

/* ============================================
   INPUTS & FORMS
   ============================================ */
.input-group {
    margin-bottom: 16px;
}

.input-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-family: var(--font-primary);
    margin-bottom: 8px;
}

.input,
.textarea,
.select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all 0.3s ease;

    clip-path: polygon(
            6px 0,
            calc(100% - 6px) 0,
            100% 6px,
            100% calc(100% - 6px),
            calc(100% - 6px) 100%,
            6px 100%,
            0 calc(100% - 6px),
            0 6px
    );
}

.input:focus,
.textarea:focus,
.select:focus {
    outline: none;
    border-color: var(--cyan-bright);
    box-shadow:
            inset 0 2px 10px rgba(0, 0, 0, 0.3),
            0 0 20px rgba(0, 229, 255, 0.3);
    background: rgba(20, 35, 50, 0.95);
}

.textarea {
    resize: vertical;
    min-height: 100px;
}

.checkbox,
.radio {
    width: auto;
    margin-right: 8px;
}

/* ============================================
   NOTIFICATIONS / TOASTS
   ============================================ */
.notification {
    position: fixed;
    top: 80px;
    right: 20px;
    max-width: 400px;
    padding: 16px 20px;
    background: var(--bg-panel);
    border: 1px solid var(--border-medium);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
    animation: notificationSlideIn 0.3s ease;
    z-index: 10000;
    backdrop-filter: blur(10px);

    clip-path: polygon(
            8px 0,
            calc(100% - 8px) 0,
            100% 8px,
            100% calc(100% - 8px),
            calc(100% - 8px) 100%,
            8px 100%,
            0 calc(100% - 8px),
            0 8px
    );
}

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

.notification-success {
    border-color: var(--success);
    box-shadow: 0 0 20px rgba(0, 230, 118, 0.3);
}

.notification-warning {
    border-color: var(--warning);
    box-shadow: 0 0 20px rgba(255, 196, 0, 0.3);
}

.notification-error {
    border-color: var(--error);
    box-shadow: 0 0 20px rgba(255, 61, 0, 0.3);
}

.notification-info {
    border-color: var(--cyan-medium);
    box-shadow: 0 0 20px var(--cyan-glow);
}

/* ============================================
   MOBILE RESPONSIVENESS
   ============================================ */
@media (max-width: 768px) {
    .nav-sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        z-index: 100;
        transition: left 0.3s ease;
    }

    .nav-sidebar.mobile-open {
        left: 0;
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.8);
    }

    .modal {
        width: 95%;
    }

    .notification {
        right: 10px;
        max-width: calc(100% - 20px);
    }
}
