:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.5);
    --error-color: #ef4444;
    --success-color: #22c55e;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --border-radius: 16px;
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Info Section */
.info-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 32px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    animation: fadeInUp 0.6s ease-out 0.4s backwards;
    /* Delayed animation */
}

.info-card h2 {
    font-size: 1.8rem;
    margin-bottom: 24px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
    text-align: center;
}

.info-item {
    margin-bottom: 24px;
}

.info-item:last-child {
    margin-bottom: 0;
}

.info-item h3 {
    font-size: 1.2rem;
    color: var(--accent-color);
    margin-bottom: 8px;
}

.info-item p,
.info-list li {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.95rem;
}

.info-item code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: var(--text-primary);
}

.info-list {
    list-style-type: none;
    padding-left: 10px;
}

/* Basic element styles for KB */
.info-item table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.9rem;
}

.info-item th,
.info-item td {
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    text-align: left;
    color: var(--text-primary);
}

.info-item th {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-color);
}

.info-item tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.info-item pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 16px 0;
    font-family: monospace;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.info-list li {
    margin-bottom: 6px;
    position: relative;
    padding-left: 16px;
}

.info-list li::before {
    content: '•';
    color: var(--accent-color);
    position: absolute;
    left: 0;
    font-weight: bold;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    /* Use block or flex-column with safe centering */
    display: flex;
    flex-direction: column;
    align-items: center;
    /* removed justify-content: center to avoid top-clipping on overflow */
    padding: 20px 16px;
    /* Reduced side padding for mobile */
}

/* Background Effects */
.background-globes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.globe {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
}

.globe-1 {
    width: 400px;
    height: 400px;
    background: #4f46e5;
    top: -100px;
    left: -100px;
    animation: float 10s infinite alternate;
}

.globe-2 {
    width: 300px;
    height: 300px;
    background: #0ea5e9;
    bottom: -50px;
    right: -50px;
    animation: float 12s infinite alternate-reverse;
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(30px, 30px);
    }
}

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    /* Increased for DB column */
    display: flex;
    flex-direction: column;
    gap: 24px;
    z-index: 1;
}

/* Grid Layout - Simplified */
.content-grid {
    display: flex;
    flex-direction: column;
    gap: 32px;
    width: 100%;
}

/* Removed left/right column splits for cleaner stacked flow with full width */

.app-header {
    text-align: center;
    animation: fadeInDown 0.6s ease-out;
}

.app-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    background: linear-gradient(to right, #60a5fa, #38bdf8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.app-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Card Styles */
.calculator-card,
.results-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 32px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    animation: fadeInUp 0.6s ease-out 0.2s backwards;
}

/* Inputs */
.input-group {
    margin-bottom: 20px;
    position: relative;
    width: 100%;
}

.split-row {
    display: flex;
    gap: 20px;
    width: 100%;
}

.split-row .input-group {
    flex: 1;
    min-width: 0;
}

.input-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: #cbd5e1;
    font-weight: 500;
}

/* Tooltip Styles */
.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 0.75rem;
    color: var(--accent-color);
    cursor: help;
    position: relative;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.tooltip-icon:hover {
    opacity: 1;
}

.tooltip-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 400;
    width: max-content;
    max-width: 250px;
    line-height: 1.4;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1000;
    pointer-events: none;
}

.tooltip-icon:hover::after {
    opacity: 1;
    visibility: visible;
}

input,
select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    font-family: monospace;
}

input:focus,
select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

/* Validation States */
input.input-error {
    border-color: var(--error-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

input.input-valid {
    border-color: var(--success-color);
}

.error-msg {
    color: var(--error-color);
    font-size: 0.85rem;
    margin-top: 6px;
    display: block;
    min-height: 1.2em;
}

/* Button Group */
.btn-group {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

/* Primary Button - Enhanced */
.primary-btn {
    flex: 1;
    padding: 16px 24px;
    background: linear-gradient(135deg, #3b82f6, #0ea5e9);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(14, 165, 233, 0.4);
}

.primary-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(14, 165, 233, 0.3);
}

/* Secondary Button (Reset) */
.secondary-btn {
    padding: 16px 24px;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    border-color: rgba(255, 255, 255, 0.4);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Results */
.results-card h2 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
}

.results-grid {
    display: grid;
    gap: 16px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    /* Spacing for wrapping */
    padding: 12px;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.result-item .label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.result-item .value {
    color: var(--accent-color);
    font-weight: 600;
    font-family: monospace;
    font-size: 1rem;
}

/* Value with Copy Button */
.value-with-copy {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Copy Button Styles */
.copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.copy-btn:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.copy-btn.copied {
    background: rgba(34, 197, 94, 0.2);
    border-color: var(--success-color);
    color: var(--success-color);
}

/* Copy Table Button */
.copy-table-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* Subnet Header */
.subnet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.subnet-header h3 {
    color: var(--text-primary);
    margin: 0;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Division Section */
.division-section {
    margin-top: 10px;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 20px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.divider span {
    padding: 0 10px;
}

/* Subnet Table */
.table-responsive {
    overflow-x: auto;
}

.subnet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: left;
}

.subnet-table th,
.subnet-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.subnet-table th {
    color: var(--text-secondary);
    font-weight: 600;
}

.subnet-table td {
    color: var(--text-primary);
    font-family: monospace;
}

.subnet-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Responsive */
@media (max-width: 900px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .app-header h1 {
        font-size: 2rem;
    }

    .calculator-card,
    .results-card,
    .info-card {
        padding: 16px;
    }

    .result-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .result-item .label {
        width: 100%;
        margin-bottom: 4px;
        color: var(--text-secondary);
        font-size: 0.85rem;
    }

    .result-item .value-with-copy {
        width: 100%;
        display: flex;
        justify-content: space-between;
        /* Value left, Copy btn right */
        align-items: center;
    }
}

/* Accordion Styles */
.accordion-section {
    margin-top: 32px;
}

.accordion-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.accordion-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
    text-align: left;
    border: none;
    padding: 0;
}

.accordion-header .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--accent-color);
    font-size: 1.5rem;
    font-weight: bold;
    transition: transform 0.3s ease, background 0.3s ease;
}

.accordion-header:hover .icon {
    background: rgba(56, 189, 248, 0.2);
}

.accordion-header.active .icon {
    transform: rotate(45deg);
    /* Turn + to x */
    background: rgba(239, 68, 68, 0.2);
    /* Reddish tint */
    color: var(--error-color);
}

.accordion-content {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================
   AdSense Container Styles
   ================================ */

/* Banner Ads (Header, Footer, Inside Card) */
.ad-banner {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 90px;
    /* Standard banner height */
}

#ad-header-banner {
    margin-top: 16px;
    margin-bottom: 24px;
}

.ad-inside-card {
    margin-top: 24px;
    margin-bottom: 16px;
}

.ad-footer {
    margin-top: 32px;
    margin-bottom: 32px;
}

/* Sidebar Ads (Desktop Only) */
.ad-sidebar {
    display: none;
    /* Hidden by default (mobile) */
    position: fixed;
    top: 160px;
    /* Equivalent to top-40 (10rem) */
    flex-direction: column;
    justify-content: flex-start;
    width: 160px;
    /* Standard sidebar ad width */
    min-height: 600px;
    /* Standard sidebar ad height */
    z-index: 100;
}

.ad-sidebar-left {
    left: 16px;
    /* Equivalent to left-4 (1rem) */
}

.ad-sidebar-right {
    right: 16px;
    /* Equivalent to right-4 (1rem) */
}

/* Show sidebars on large screens (lg: 1024px+) */
@media (min-width: 1024px) {
    .ad-sidebar {
        display: flex;
    }

    /* Add padding to body so sidebars don't overlap content */
    body {
        padding-left: 200px;
        padding-right: 200px;
    }
}

/* Ensure AdSense ins tags are responsive */
.adsbygoogle {
    display: block;
    width: 100%;
}

/* ================================
   DEBUG: Ad Placeholder Styles
   Remove these when going live!
   ================================
.ad-banner,
.ad-sidebar {
    background: rgba(56, 189, 248, 0.1);
    border: 2px dashed var(--accent-color);
    border-radius: 8px;
}

.ad-banner::before,
.ad-sidebar::before {
    content: 'AD PLACEHOLDER';
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    min-height: 90px;
    color: var(--accent-color);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 2px;
    opacity: 0.7;
}

.ad-sidebar::before {
    min-height: 250px;
}
*/

/* ================================
   Site Footer Styles
   ================================ */
.site-footer {
    text-align: center;
    padding: 24px 16px;
    margin-top: 32px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.site-footer p {
    margin: 4px 0;
}

.site-footer p:first-child {
    font-weight: 500;
}

.site-footer p:last-child {
    font-size: 0.85rem;
    opacity: 0.8;
}