/* Cards */
/* Cards */
.card {
    background: var(--bg-card);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: rgba(99, 102, 241, 0.3);
}

.card h3 {
    margin-bottom: var(--spacing-md);
    font-size: 1.1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* Grid Systems */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-lg);
}

/* Buttons */
/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-family: var(--font-heading);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    font-size: 0.95rem;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--gradient-hover);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

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

.btn-secondary {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: var(--bg-body);
    border-color: var(--text-muted);
}

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

/* Inputs */
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Date Input Specifics */
input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    padding-right: 10px;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    filter: invert(0.5);
    /* Default gray */
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    /* White for dark mode */
}

/* Tool Specifics */

/* Speed Test Gauge */
.speed-gauge-container {
    text-align: center;
    margin: var(--spacing-xl) 0;
}

.speed-gauge {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 10px solid var(--border-color);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    /* transition: border-color 0.3s ease; Removed border transition from container */
}

.gauge-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 10px solid var(--border-color);
    border-top-color: transparent;
    /* Initial state */
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.gauge-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.speed-gauge.active .gauge-ring {
    border-color: var(--primary-color);
    border-top-color: var(--secondary-color);
    animation: spin 1s linear infinite;
}

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

.speed-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-main);
}

.speed-unit {
    font-size: 1rem;
    color: var(--text-muted);
}

.speed-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.metric-card {
    background: var(--bg-body);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    text-align: center;
}

.metric-val {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.metric-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}



/* Result Box */
.result-box {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background-color: var(--bg-body);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
    font-family: 'Fira Code', monospace;
    white-space: pre-wrap;
    word-break: break-all;
}

.result-box.hidden {
    display: none;
}

/* Tool Notes */
.tool-notes {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background-color: rgba(99, 102, 241, 0.05);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.tool-notes h3 {
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
    color: var(--text-main);
}

.tool-notes h3:first-child {
    margin-top: 0;
}

.tool-notes h4 {
    color: var(--primary-color);
    margin-bottom: var(--spacing-xs);
    display: flex;
    align-items: center;
    gap: 6px;
}

.tool-notes ul {
    padding-left: 1.2rem;
}

/* Text Diff Tool */
.diff-view {
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    background: var(--bg-body);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.diff-row {
    display: flex;
    width: 100%;
}

.diff-ln {
    display: inline-block;
    width: 40px;
    min-width: 40px;
    text-align: right;
    padding-right: 10px;
    color: var(--text-muted);
    user-select: none;
    border-right: 1px solid var(--border-color);
    margin-right: 10px;
    opacity: 0.7;
}

/* Regex Tester */
.regex-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
}

@media (max-width: 768px) {
    .regex-container {
        grid-template-columns: 1fr;
    }
}

.regex-content {
    font-family: monospace;
    white-space: pre-wrap;
    padding: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    min-height: 50px;
    max-height: 300px;
    overflow-y: auto;
}

.highlight {
    background-color: #ffd700;
    color: #000;
    border-radius: 2px;
}

[data-theme="dark"] .highlight {
    background-color: #b8860b;
    color: #fff;
}

.regex-reference-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ref-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9em;
}

.ref-item:last-child {
    border-bottom: none;
}

.ref-item code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: var(--primary-color);
}

/* Cron Maker Tabs */
.cron-maker-container {
    width: 100%;
    margin-bottom: 20px;
}

.cron-tabs {
    display: flex;
    gap: 5px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
    overflow-x: auto;
    flex-wrap: nowrap;
    /* Default to nowrap for desktop scrolling if needed, or wrap? Original was auto overflow */
}

@media (max-width: 768px) {
    .cron-tabs {
        flex-wrap: wrap;
        overflow-x: visible;
        gap: 8px;
    }

    .cron-tab {
        flex: 1 1 auto;
        /* Grow to fill space */
        text-align: center;
        font-size: 0.9rem;
        padding: 8px 12px;
    }
}

.cron-tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
    font-size: 1.1rem;
    font-family: var(--font-heading);
}

.cron-tab:hover {
    color: var(--primary-color);
}

.cron-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.cron-pane {
    display: none;
    padding: 10px;
    animation: fadeIn 0.3s ease;
}

.cron-pane.active {
    display: block;
}

.form-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.week-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 10px;
}

.week-grid label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

/* Advanced Inputs (reusing cron-field styles) */
.cron-inputs {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.cron-field input {
    width: 150px;
    height: 40px;
    font-size: 1.2rem;
}

.diff-content {
    flex-grow: 1;
    white-space: pre-wrap;
    word-break: break-all;
}

.diff-add {
    background-color: rgba(16, 185, 129, 0.15);
    /* Green 500 with opacity */
}

.diff-add .diff-content {
    color: #065f46;
}

[data-theme="dark"] .diff-add {
    background-color: rgba(16, 185, 129, 0.2);
}

[data-theme="dark"] .diff-add .diff-content {
    color: #a7f3d0;
}

.diff-del {
    background-color: rgba(239, 68, 68, 0.15);
    /* Red 500 with opacity */
}

.diff-del .diff-content {
    color: #991b1b;
}

[data-theme="dark"] .json-boolean {
    color: #f87171;
}

[data-theme="dark"] .json-null {
    color: #f87171;
}

/* JSON Tree View */
.json-tree {
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    padding: 10px;
}

.json-tree-node {
    margin-left: 20px;
}

.json-tree-row {
    display: flex;
    align-items: flex-start;
    cursor: default;
    padding: 2px 0;
}

.json-tree-row:hover {
    background-color: rgba(99, 102, 241, 0.05);
}

.json-tree-toggle {
    cursor: pointer;
    user-select: none;
    margin-right: 5px;
    color: var(--text-muted);
    font-size: 0.8em;
    width: 12px;
    display: inline-block;
    transition: transform 0.1s ease;
}

.json-tree-toggle.collapsed {
    transform: rotate(-90deg);
}

.json-tree-key {
    color: var(--primary-color);
    margin-right: 5px;
}

.json-tree-preview {
    color: var(--text-muted);
    font-style: italic;
    margin-left: 5px;
    font-size: 0.85em;
}

.json-tree-bracket {
    color: var(--text-main);
    font-weight: bold;
}

/* QR Code Generator */
#qr-output {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Anchor to top to prevent jump */
    padding-top: 40px;
    min-height: 450px;
    /* Increased slightly */
    padding-bottom: var(--spacing-lg);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

#qr-code-wrapper {
    padding: 15px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    /* Prevent stretching */
    margin-bottom: 20px;
    /* Space for button */
}

#qr-output img {
    display: block;
    /* Remove inline gap */
    max-width: 100%;
}

/* Interactive Cron Editor */
/* Interactive Cron Editor */
.cron-editor.multi-field-mode {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.cron-field {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cron-input-field {
    font-family: 'Fira Code', monospace;
    font-size: 2.5rem;
    font-weight: 500;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-main);
    text-align: center;
    width: 150px;
    padding: 10px 0;
    outline: none;
    transition: all 0.2s ease;
}

@media (max-width: 768px) {
    .cron-input-field {
        width: 100px;
        font-size: 1.8rem;
    }
}

.cron-input-field:focus {
    border-bottom-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
    border-radius: 4px 4px 0 0;
    transform: translateY(-2px);
}

.cron-field-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cron-field-range {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.cron-human-text {
    font-size: 1.4rem;
    color: var(--text-main);
    text-align: center;
    font-weight: 500;
    min-height: 1.5em;
    margin-bottom: var(--spacing-lg);
    opacity: 0.9;
}

/* Cron Guide Styles */
.cron-guide-grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
}

.cron-guide-column {
    display: flex;
    flex-direction: column;
}

.cron-guide-header {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

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

.cron-table td {
    padding: 8px 12px;
    background: var(--bg-secondary);
}

.cron-table td:first-child {
    border-radius: 6px 0 0 6px;
    width: 50px;
    text-align: center;
}

.cron-table td:last-child {
    border-radius: 0 6px 6px 0;
}

.cron-code {
    color: var(--accent-color);
    font-family: 'Fira Code', monospace;
    font-weight: bold;
    font-size: 1.1em;
}

.cron-desc {
    color: var(--text-muted);
    font-size: 0.95em;
}

.cron-preset-select {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.cron-preset-select:hover,
.cron-preset-select:focus {
    border-color: var(--primary-color);
    outline: none;
}

.cron-pill {
    padding: 8px 20px;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.cron-pill:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.cron-pill.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.cron-config-section {
    max-width: 800px;
    margin: 0 auto;
}

.cron-pane {
    animation: fadeIn 0.3s ease;
}

/* Hide old tabs if any remain */
.cron-tabs {
    display: none;
}

/* Re-enable for financial calculators if they use it, but we should update them too or scope this */
/* Re-enable for financial calculators if they use it, but we should update them too or scope this */
#view-finance .cron-tabs,
#view-interest .cron-tabs,
#view-time-diff .cron-tabs {
    display: flex;
    /* Keep financial tabs working */
}

[data-theme="dark"] .diff-del {
    background-color: rgba(239, 68, 68, 0.2);
}

[data-theme="dark"] .diff-del .diff-content {
    color: #fecaca;
}

.diff-equal {
    color: var(--text-muted);
}

/* Editor with Line Numbers */
.editor-wrapper {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    overflow-y: auto;
    /* Enable vertical scrolling on wrapper */
    height: 200px;
    /* Limit height */
}

.editor-wrapper .line-numbers {
    width: 40px;
    background: var(--bg-body);
    color: var(--text-muted);
    text-align: right;
    padding: 10px 5px;
    font-family: monospace;
    font-size: 13.3333px;
    /* Match textarea default */
    line-height: normal;
    /* Match textarea default */
    border-right: 1px solid var(--border-color);
    user-select: none;
    min-height: 100%;
    /* Ensure it fills height */
    white-space: pre;
}

.editor-wrapper textarea {
    flex: 1;
    border: none !important;
    border-radius: 0 !important;
    resize: none;
    padding: 10px;
    margin: 0;
    outline: none;
    background: transparent;
    color: var(--text-main);
    line-height: normal;
    overflow-y: hidden;
    /* Hide textarea scrollbar, use wrapper */
    min-height: 100%;
    /* Ensure it fills height */
}

/* IP Info Details */
.detail-row {
    display: flex;
    justify-content: flex-start;
    align-items: baseline;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--border-color);
    gap: var(--spacing-lg);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row .label {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    min-width: 100px;
    flex-shrink: 0;
}

.detail-row .value {
    color: var(--text-main);
    font-weight: 600;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    text-align: left;
    word-break: break-all;
}

/* Responsive Grid Utility */
.responsive-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
}

@media (max-width: 768px) {
    .responsive-grid {
        grid-template-columns: 1fr;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    left: auto !important;
    width: auto !important;
    max-width: 400px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    gap: 10px !important;
    z-index: 2147483647 !important;
    pointer-events: none !important;
}

.toast {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid var(--accent-color);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
    animation: slideIn 0.3s ease forwards;
    font-size: 0.9rem;
    font-weight: 500;
    pointer-events: auto !important;
}

.toast.error {
    background-color: #ef4444 !important;
    color: white !important;
    border-left-color: #991b1b !important;
}

.toast.success {
    background-color: #10b981 !important;
    color: white !important;
    border-left-color: #065f46 !important;
}

.toast.hiding {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

@keyframes fadeOut {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}