/* Pirate Theme Color Palette */
:root {
    --navy: #1a1a3e;
    --navy-dark: #0f0f2e;
    --gold: #d4af37;
    --gold-light: #e8d572;
    --crimson: #8b0000;
    --crimson-light: #b22222;
    --cream: #f5e6d3;
    --brown: #5c4033;
    --white: #ffffff;
}

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

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 100%);
    color: var(--cream);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    padding: 30px 20px;
    background: rgba(26, 26, 62, 0.8);
    border: 3px solid var(--gold);
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.3);
}

header h1 {
    font-size: 2.5em;
    color: var(--gold);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 10px;
}

.subtitle {
    font-style: italic;
    color: var(--gold-light);
    font-size: 1.1em;
}

.input-section {
    background: rgba(26, 26, 62, 0.6);
    padding: 25px;
    border-radius: 10px;
    border: 2px solid var(--gold);
    margin-bottom: 30px;
}

.input-group {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.input-group label {
    font-weight: bold;
    color: var(--gold);
    font-size: 1.1em;
    min-width: 250px;
}

#network-input {
    flex: 1;
    min-width: 200px;
    padding: 12px 15px;
    font-size: 1em;
    border: 2px solid var(--gold);
    border-radius: 5px;
    background: var(--cream);
    color: var(--navy);
    font-family: 'Courier New', monospace;
}

#network-input:focus {
    outline: none;
    border-color: var(--gold-light);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.btn {
    padding: 12px 25px;
    font-size: 1em;
    font-weight: bold;
    border: 2px solid var(--gold);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Georgia', serif;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.btn-primary:hover {
    background: var(--gold-light);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.6);
    transform: translateY(-2px);
}

.btn-divide {
    background: var(--crimson);
    color: var(--white);
    border-color: var(--crimson);
    padding: 8px 15px;
    font-size: 0.9em;
}

.btn-divide:hover {
    background: var(--crimson-light);
    box-shadow: 0 0 10px rgba(139, 0, 0, 0.5);
}

.btn-export {
    background: var(--brown);
    color: var(--cream);
    border-color: var(--brown);
}

.btn-export:hover {
    background: #6d4e41;
    box-shadow: 0 0 10px rgba(92, 64, 51, 0.5);
}

.subnets-section {
    background: rgba(26, 26, 62, 0.6);
    padding: 25px;
    border-radius: 10px;
    border: 2px solid var(--gold);
}

.subnets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.subnets-header h2 {
    color: var(--gold);
    font-size: 1.8em;
}

#export-format {
    padding: 10px 15px;
    font-size: 1em;
    border: 2px solid var(--gold);
    border-radius: 5px;
    background: var(--cream);
    color: var(--navy);
    font-family: 'Georgia', serif;
    cursor: pointer;
}

#export-format:focus {
    outline: none;
    border-color: var(--gold-light);
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--gold-light);
    font-style: italic;
    font-size: 1.2em;
}

/* Tree container */
.tree-container {
    margin-top: 20px;
}

/* Tree node structure */
.tree-node {
    display: flex;
    margin-bottom: 12px;
    align-items: flex-start;
}

.tree-node.subnet-root {
    margin-bottom: 20px;
}

.tree-node.subnet-child {
    margin-left: 0;
}

/* Tree line section - connectors and toggle */
.tree-line-section {
    display: flex;
    align-items: center;
    min-width: 30px;
    padding-top: 2px;
    margin-right: 8px;
}

.tree-vline {
    color: var(--gold);
    opacity: 0.5;
    font-family: monospace;
    font-size: 1em;
    line-height: 1;
    display: inline-block;
    width: 16px;
    text-align: center;
}

.tree-junction,
.tree-corner {
    color: var(--gold);
    opacity: 0.7;
    font-family: monospace;
    font-size: 1em;
    line-height: 1;
    display: inline-block;
    width: 20px;
}

.tree-space {
    display: inline-block;
    width: 16px;
}

.tree-toggle {
    display: inline-block;
    cursor: pointer;
    color: var(--gold);
    font-size: 1em;
    user-select: none;
    transition: all 0.2s ease;
    width: 20px;
    text-align: center;
    line-height: 1;
    margin-left: 2px;
}

.tree-toggle:hover {
    color: var(--gold-light);
    transform: scale(1.2);
}

.tree-spacer {
    display: inline-block;
    width: 22px;
}

/* Subnet card */
.subnet-card {
    flex: 1;
    background: rgba(15, 15, 46, 0.6);
    border: 2px solid var(--gold);
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s ease;
}

.tree-node.subnet-parent .subnet-card {
    border-color: var(--crimson);
    background: rgba(139, 0, 0, 0.15);
}

.tree-node.subnet-parent.expanded .subnet-card {
    border-color: var(--gold);
    background: rgba(212, 175, 55, 0.1);
}

.tree-node.subnet-leaf .subnet-card {
    border-color: var(--gold);
    background: rgba(15, 15, 46, 0.6);
}

.subnet-card:hover {
    border-color: var(--gold-light);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
    transform: translateX(2px);
}

/* Subnet header */
.subnet-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.subnet-cidr {
    font-size: 1.3em;
    font-weight: bold;
    color: var(--gold);
    font-family: 'Courier New', monospace;
}

.child-count {
    color: var(--gold-light);
    font-size: 0.9em;
    font-style: italic;
}

/* Subnet details */
.subnet-details {
    margin-bottom: 12px;
}

.detail-row {
    display: flex;
    margin-bottom: 8px;
    align-items: center;
}

.detail-row:last-child {
    margin-bottom: 0;
}

.detail-label {
    color: var(--gold-light);
    font-weight: bold;
    min-width: 100px;
    margin-right: 10px;
}

.detail-value {
    color: var(--cream);
    font-family: 'Courier New', monospace;
}

.stats-row {
    display: flex;
    gap: 30px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(212, 175, 55, 0.3);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-label {
    color: var(--gold-light);
    font-size: 0.9em;
}

.stat-value {
    color: var(--gold);
    font-weight: bold;
    font-size: 1.1em;
}

/* Subnet action */
.subnet-action {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(212, 175, 55, 0.3);
}

.max-label {
    color: #888;
    font-style: italic;
    font-size: 0.9em;
}

.monospace {
    font-family: 'Courier New', monospace;
}

.error-message {
    background: var(--crimson);
    color: var(--white);
    padding: 15px;
    border-radius: 5px;
    margin: 15px 0;
    border: 2px solid var(--crimson-light);
    font-weight: bold;
}

/* Modal for dividing subnets */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--navy);
    border: 3px solid var(--gold);
    border-radius: 10px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 4px 30px rgba(212, 175, 55, 0.5);
}

.modal-content h3 {
    color: var(--gold);
    margin-bottom: 20px;
    font-size: 1.5em;
}

.modal-content label {
    display: block;
    color: var(--gold-light);
    margin-bottom: 8px;
    font-weight: bold;
}

.modal-content input,
.modal-content select {
    width: 100%;
    padding: 10px;
    margin-bottom: 20px;
    border: 2px solid var(--gold);
    border-radius: 5px;
    background: var(--cream);
    color: var(--navy);
    font-family: 'Courier New', monospace;
    font-size: 1em;
}

.modal-content .btn-group {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.export-section {
    background: rgba(26, 26, 62, 0.6);
    padding: 25px;
    border-radius: 10px;
    border: 2px solid var(--gold);
    margin-top: 30px;
}

.export-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.export-section h2 {
    color: var(--gold);
    font-size: 1.8em;
    margin: 0;
}

.export-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

#export-output {
    width: 100%;
    min-height: 300px;
    padding: 15px;
    font-size: 0.9em;
    border: 2px solid var(--gold);
    border-radius: 5px;
    background: var(--cream);
    color: var(--navy);
    font-family: 'Courier New', monospace;
    resize: vertical;
    white-space: pre;
    overflow-x: auto;
}

#export-output:focus {
    outline: none;
    border-color: var(--gold-light);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .input-group label {
        min-width: auto;
    }

    .subnets-header {
        flex-direction: column;
        align-items: stretch;
    }

    .subnet-card {
        padding: 12px;
    }

    .subnet-cidr {
        font-size: 1.1em;
    }

    .detail-label {
        min-width: 80px;
        font-size: 0.9em;
    }

    .stats-row {
        flex-direction: column;
        gap: 8px;
    }

    #export-output {
        font-size: 0.8em;
        min-height: 200px;
    }
}

