/* index.css - Core Design System */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --danger: #ef4444;
    --glass: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    gap: 0.5rem;
    text-decoration: none;
    font-size: 0.875rem;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

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

.btn-danger:hover {
    background-color: #dc2626;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: white;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--primary);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #6366f1, #a855f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Dashboard Container & Groups */
.dashboard-container {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.dashboard-group {
    margin-bottom: 3rem;
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 50;
}

.group-title-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.collapse-toggle {
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: color 0.2s;
    user-select: none;
    width: 20px;
}

.collapse-toggle:hover {
    color: var(--primary);
}

.group-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.group-actions {
    display: flex;
    gap: 0.5rem;
}

.group-content {
    transition: max-height 0.3s ease-out, opacity 0.2s;
    overflow: hidden;
    max-height: 2000px;
    opacity: 1;
}

.group-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.element-card {
    position: relative;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    cursor: grab;
    transition: all 0.2s;
    padding: 1.15rem 1rem;
}

.element-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 20px -8px rgba(0, 0, 0, 0.5);
}

@keyframes card-hover {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-5px);
    }
}

/* Toggle Switch - Large & Premium */
.switch {
    position: relative;
    display: inline-block;
    width: 80px;
    height: 44px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.05);
    transition: .4s;
    border-radius: 44px;
    border: 1px solid var(--border);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.slider:before {
    position: absolute;
    content: "";
    height: 36px;
    width: 36px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

input:checked+.slider {
    background-color: var(--switch-color, var(--primary));
    border-color: var(--switch-color, var(--primary));
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--switch-color, var(--primary));
}

input:checked+.slider:before {
    transform: translateX(36px);
}

/* Syncing Animation - Enhanced Pulse */
.syncing-wrapper {
    position: relative;
}

.syncing-pulse {
    animation: sync-pulse 1.2s infinite ease-in-out;
    pointer-events: none;
}

@keyframes sync-pulse {
    0% {
        filter: brightness(1) blur(0px);
        opacity: 1;
        transform: scale(1);
    }

    50% {
        filter: brightness(1.8) blur(1.1px);
        opacity: 0.7;
        transform: scale(1.03);
    }

    100% {
        filter: brightness(1) blur(0px);
        opacity: 1;
        transform: scale(1);
    }
}


.stale-dot {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--danger);
    z-index: 5;
}

.grid-span-3 {
    grid-column: span 3;
}

/* Templates */
.template-percent {
    width: 100%;
    padding: 0 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.percent-number {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.progress-container {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
}

.progress-bar {
    height: 100%;
    border-radius: 6px;
    transition: width 0.5s ease-out;
}

.percent-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.template-gauge {
    position: relative;
    width: 140px;
    height: 140px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin: 0 auto;
}

.gauge-svg {
    transform: rotate(135deg);
    width: 100%;
    height: 100%;
}

.gauge-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 10;
    stroke-dasharray: 188.5 251.3;
    stroke-linecap: round;
    /* radius 40 * PI * 1.5 */
}

.gauge-prog {
    fill: none;
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s ease-out;
}

.gauge-value {
    font-size: 1.2rem;
    font-weight: 800;
}

.gauge-unit {
    font-size: 0.6rem;
    font-weight: 400;
}

.element-icon {
    pointer-events: auto;
    z-index: 10;
}

/* Toast Notification Styling */
#copy-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #6366f1;
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: 800;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#copy-toast.show {
    opacity: 1;
}

.gauge-label-small {
    font-size: 0.4rem;
    fill: var(--text-muted);
    transform: rotate(-135deg);
    transform-origin: center;
}

.card-actions {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0.7;
    /* Always visible but slightly faded */
    z-index: 20;
    transition: all 0.2s;
}

.element-card:hover .card-actions {
    opacity: 1;
}

.action-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: none;
    border-radius: 0.4rem;
    padding: 0.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: var(--primary);
    color: white;
}

.action-btn.delete-btn:hover {
    background: var(--danger);
}

/* Symbol Picker Styles */

.symbol-picker-trigger:hover {
    border-color: var(--primary) !important;
}

.symbol-item:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary) !important;
    transform: scale(1.1);
}

.symbol-picker-popup .modal-content {
    background: #1e293b;
    border: 1px solid var(--border);
}


.placeholder-card {
    border: 2px dashed var(--border);
    background: transparent;
    border-radius: 1rem;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--border);
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.placeholder-card:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

/* Modals */
.modal {
    display: none;
    /* Changed to flex by JS */
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    overflow-y: auto;
    padding: 2rem 1rem;
    box-sizing: border-box;
    display: none;
    align-items: flex-start;
    justify-content: center;
}

.modal-content {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 900px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    margin: auto;
    position: relative;
}

.modal h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--bg-card);
    min-width: 180px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    overflow: hidden;
    margin-top: 0.5rem;
    z-index: 1000;
}

.dropdown-content a {
    color: var(--text-main);
    padding: 0.75rem 1rem;
    text-decoration: none;
    display: block;
    font-size: 0.875rem;
}

.dropdown-content a:hover {
    background: rgba(255, 255, 255, 0.05);
}

.show {
    display: block;
}

.text-danger {
    color: var(--danger);
}

body.modal-open {
    overflow: hidden !important;
}

/* Textfield Template */
.template-textfield {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-align: center;
    padding: 0;
    box-sizing: border-box;
    flex: 1;
    min-height: 80px;
}

.template-textfield .prefix,
.template-textfield .suffix {
    font-size: 0.9rem;
    opacity: 0.6;
    font-weight: 400;
}

.template-textfield .main-text {
    font-size: 2.2rem;
    font-weight: 800;
    margin: 0.25rem 0;
    line-height: 1.1;
    word-break: break-word;
}

/* Smaller text if it's very long */
.template-textfield .main-text:not(:empty) {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Table Template */
.template-table {
    mask-image: linear-gradient(to bottom, black 95%, transparent 100%);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.template-table::-webkit-scrollbar {
    width: 4px;
}

.template-table::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}