@import url('/styles/shared.css');

/* Layout & Form */
.subnet-form {
    margin-top: 1rem;
}

.subnet-form .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.25rem;
    align-items: end;
}

.subnet-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #1f2937;
}

.subnet-form input,
.subnet-form select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: #ffffff;
}

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

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #38bdf8 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.85rem 1.9rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 40px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
    margin-left: 0.75rem;
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.85rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 10px 28px rgba(75, 85, 99, 0.28);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(75, 85, 99, 0.33);
}

/* Column selector */
.columns-section {
    margin-top: 2.25rem;
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.06);
}

.columns-section h4 {
    margin-bottom: 1rem;
    color: #1f2937;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.columns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.column-checkbox {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    color: #1f2937;
}

.column-checkbox:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(59, 130, 246, 0.15);
}

.column-checkbox input {
    display: none;
}

.column-checkbox .checkmark {
    position: relative;
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 2px solid #cbd5f5;
    background: #ffffff;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.column-checkbox input:checked ~ .checkmark {
    background: linear-gradient(135deg, #2563eb 0%, #38bdf8 100%);
    border-color: transparent;
}

.column-checkbox .checkmark::after {
    content: '';
    position: absolute;
    display: none;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.column-checkbox input:checked ~ .checkmark::after {
    display: block;
}

/* Info top bar */
.simple-info {
    margin-top: 2.25rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.1rem;
}

.info-item {
    background: #ffffff;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    padding: 1.3rem;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.07);
}

.info-label {
    display: block;
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.55px;
}

.info-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Results table */
.result-table {
    margin-top: 2.5rem;
    border-radius: 18px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 22px 56px rgba(15, 23, 42, 0.08);
    padding: 1.25rem;
    overflow-x: auto;
    max-width: 100%;
}

.result-table::-webkit-scrollbar {
    height: 8px;
}

.result-table::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.4);
    border-radius: 999px;
}

.result-table::-webkit-scrollbar-track {
    background: rgba(226, 232, 240, 0.6);
    border-radius: 999px;
}

.modern-subnet-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    border-radius: 16px;
    overflow: hidden;
    background: #ffffff;
    font-size: 0.85rem;
}

.modern-subnet-table thead {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modern-subnet-table th,
.modern-subnet-table td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    font-size: 0.85rem;
    white-space: nowrap;
}

.modern-subnet-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.modern-subnet-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.1);
    transition: background 0.2s ease;
}

.modern-subnet-table .data-subnet,
.modern-subnet-table .data-range {
    font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
    color: #0f172a;
    white-space: nowrap;
    font-size: 0.82rem;
}

.modern-subnet-table .data-useable,
.modern-subnet-table .data-hosts {
    font-weight: 600;
    color: #1d4ed8;
    font-size: 0.82rem;
}

/* Hierarchy row coloring */
.subnet-level-0 td { background: rgba(15, 23, 42, 0.02); }
.subnet-level-1 td { background: rgba(56, 189, 248, 0.08); }
.subnet-level-2 td { background: rgba(16, 185, 129, 0.08); }
.subnet-level-3 td { background: rgba(251, 191, 36, 0.1); }
.subnet-level-4 td { background: rgba(248, 113, 113, 0.1); }

.subnet-level-0:hover td,
.subnet-level-1:hover td,
.subnet-level-2:hover td,
.subnet-level-3:hover td,
.subnet-level-4:hover td {
    background: rgba(59, 130, 246, 0.14);
}

.subnet-address {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.hierarchy-indicator {
    display: flex;
    align-items: center;
    position: relative;
    gap: 0.25rem;
    min-width: 26px;
}

.hierarchy-line {
    position: relative;
    display: inline-block;
    width: 12px;
    height: 18px;
}

.hierarchy-line::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    background: rgba(59, 130, 246, 0.35);
    transform: translateX(-50%);
    border-radius: 999px;
}

.hierarchy-corner::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 8px;
    height: 8px;
    border-left: 2px solid rgba(59, 130, 246, 0.45);
    border-bottom: 2px solid rgba(59, 130, 246, 0.45);
    border-radius: 0 0 0 4px;
    transform: translateX(-50%);
}

.expand-btn {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: none;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.18) 0%, rgba(14, 165, 233, 0.18) 100%);
    color: #1d4ed8;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 5px 12px rgba(59, 130, 246, 0.18);
}

.expand-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.25);
}

.expand-spacer {
    color: rgba(100, 116, 139, 0.6);
    font-size: 1.1rem;
    padding: 0 0.15rem;
}

/* Action buttons */
.btn-divide,
.btn-join {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    min-width: 74px;
}

.btn-divide {
    background: rgba(34, 197, 94, 0.16);
    color: #15803d;
    box-shadow: 0 8px 24px rgba(34, 197, 94, 0.22);
}

.btn-divide:hover {
    background: rgba(22, 163, 74, 0.24);
    transform: translateY(-1px);
}

.btn-join {
    background: rgba(59, 130, 246, 0.18);
    color: #1d4ed8;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.22);
}

.btn-join:hover {
    background: rgba(37, 99, 235, 0.24);
    transform: translateY(-1px);
}

.action-disabled {
    color: #94a3b8;
    font-style: italic;
}

.action-warning {
    color: #f59e0b;
    font-weight: 600;
}

/* Description & examples */
.description-section {
    margin-top: 3rem;
    background: #ffffff;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 26px 64px rgba(15, 23, 42, 0.1);
    padding: 2.85rem;
}

.description-header {
    color: #0f172a;
    font-size: 1.75rem;
    margin-bottom: 1.75rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e0f2fe;
}

.description-content {
    display: flex;
    flex-direction: column;
    gap: 2.75rem;
}

.description-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 2rem;
}

.description-column h3 {
    color: #1d4ed8;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.description-column p,
.description-column li {
    color: #475569;
    line-height: 1.7;
}

.description-column ul {
    margin: 0;
    padding-left: 1.15rem;
}

.description-features h3,
.description-examples h3,
.description-tips h3 {
    color: #0f172a;
    font-size: 1.35rem;
    margin-bottom: 1.5rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.75rem;
}

.feature-item {
    display: flex;
    gap: 1rem;
    padding: 1.35rem 1.6rem;
    border-radius: 16px;
    border: 1px solid #c7d2fe;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.08) 0%, rgba(56, 189, 248, 0.12) 100%);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 42px rgba(59, 130, 246, 0.16);
}

.feature-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.feature-text h4 {
    margin: 0 0 0.5rem 0;
    color: #1d4ed8;
}

.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.75rem;
}

.example-card {
    padding: 1.6rem;
    border-radius: 16px;
    border: 1px solid #c7d2fe;
    background: #eef2ff;
    box-shadow: 0 18px 44px rgba(79, 70, 229, 0.16);
}

.description-tips .tips-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tip-item {
    padding: 1.15rem 1.45rem;
    border-radius: 16px;
    background: #fef3c7;
    border-left: 5px solid #f59e0b;
    color: #92400e;
    line-height: 1.6;
}

.tip-item strong {
    color: #b45309;
}

/* Responsive */
@media (max-width: 768px) {
    .subnet-form .form-grid {
        grid-template-columns: 1fr;
    }

    .btn-secondary {
        margin-left: 0;
        margin-top: 0.75rem;
    }

    .columns-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }

    .result-table {
        padding: 1.25rem;
    }

    .description-section {
        padding: 2.25rem;
    }
}

@media (max-width: 576px) {
    .result-table,
    .description-section {
        padding: 1.8rem;
    }

    .modern-subnet-table {
        min-width: 520px;
    }

    .columns-grid {
        grid-template-columns: 1fr;
    }
}
