/* Universal box-sizing rule */
* {
    box-sizing: border-box;
}

/* ========== DARK THEME GLOBAL STYLES ========== */
html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    background-color: #121212;
    color: #e0e0e0;
    height: 100vh;
    overflow: hidden;
}

/* ADDED: Generic helper class */
.hidden {
    display: none !important;
}

/* ========== UPLOAD FORM STYLES ========== */
#upload-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 20px;
    text-align: center;
    background-color: #1e1e1e;
    color: #e0e0e0;
}
#upload-section a {
    color: #80c0ff;
}

#upload-form {
    background-color: #2a2a2a;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 500px;
}

.drop-zone {
    border: 2px dashed #616161;
    border-radius: 5px;
    padding: 30px;
    text-align: center;
    margin-bottom: 20px;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.drop-zone.highlight {
    background-color: #3a3a3a;
    border-color: #80c0ff;
}

.file-input-wrapper {
    margin-bottom: 15px;
}

.file-input-wrapper label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #333;
    color: #e0e0e0;
}

input[type="file"]::file-selector-button {
    background-color: #80c0ff;
    color: #121212;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 10px;
    transition: background-color 0.2s ease;
}

input[type="file"]::file-selector-button:hover {
    background-color: #6a9bdc;
}

button[type="submit"] {
    background-color: #4CAF50;
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

button[type="submit"]:hover {
    background-color: #45a049;
}

#upload-message {
    margin-top: 20px;
    min-height: 1.2em;
    font-weight: bold;
}

/* ========== HEATMAP CONTAINER ========== */
#heatmap-section {
    display: none; /* Hidden by default */
    width: 100%;
    height: 100vh; 
    position: relative;
    cursor: move; 
}

#heatmap-svg {
    width: 100%;
    height: 100%;
    display: block; 
}

/* ========== HEATMAP RECTANGLES & TEXT ========== */
.node rect {
    stroke: #121212; 
    stroke-width: 0px;
    cursor: pointer;
    transition: opacity 0.2s ease-in-out;
    shape-rendering: crispEdges;
}

.node:hover rect {
    opacity: 0.8;
    stroke: #e0e0e0; 
    stroke-width: 1.5px;
}

.node text {
    fill: #fff;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ========== TOOLTIP STYLES ========== */
#tooltip {
    position: absolute;
    visibility: hidden;
    background-color: rgba(40, 40, 40, 0.9);
    color: #fff;
    text-align: left;
    border-radius: 5px;
    padding: 0.75rem;
    z-index: 2000;
    white-space: nowrap;
    font-size: 0.9rem;
    pointer-events: none;
    transition: opacity 0.2s;
    opacity: 0;
    border: 1px solid #555;
}

#tooltip.visible {
    visibility: visible;
    opacity: 1;
}

/* ========== DETAIL VIEW (Overlay) ========== */
#detailView {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #121212;
    padding: 2rem;
    box-sizing: border-box;
    display: none;
    overflow-y: auto;
    z-index: 1500;
}

#backButton {
    margin-bottom: 1.5rem;
    cursor: pointer;
    color: #80c0ff;
    text-decoration: none;
    font-size: 1.1rem;
    display: inline-block;
}
#backButton:hover {
    text-decoration: underline;
}

 #detailView h2 {
     margin-top: 0;
     margin-bottom: 1.5rem;
     border-bottom: 2px solid #333;
     padding-bottom: 1rem;
 }
 
 #companyInfo p {
    line-height: 1.6;
 }
 #companyInfo strong {
    color: #aaa;
 }

#chartContainer {
    width: 100%;
    max-width: 900px;
    height: 400px;
    margin: 2rem auto;
    position: relative;
}

/* ========== TRANSACTION LIST STYLES ========== */
#transactionList {
    width: 100%;
    max-width: 900px;
    margin: 2rem auto;
}

#transactionList h3 {
    border-bottom: 1px solid #444;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

#transactionList ul {
    list-style-type: none;
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #333;
    border-radius: 5px;
}

#transactionList li {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #2a2a2a;
}
#transactionList li:last-child {
    border-bottom: none;
}

#transactionList .date {
    color: #aaa;
    flex-basis: 30%;
}
#transactionList .type {
    font-weight: bold;
    flex-basis: 20%;
    text-align: center;
}
#transactionList .type.type-buy {
    color: #4CAF50; /* Green */
}
#transactionList .type.type-sell {
    color: #f44336; /* Red */
}

#transactionList .amount {
    font-family: monospace;
    flex-basis: 50%;
    text-align: right;
}

/* ========== BUTTONS & MODALS ========== */
#info-button, #share-button {
    position: absolute;
    top: 20px;
    width: 40px;
    height: 40px;
    background-color: rgba(42, 42, 42, 0.8);
    color: #e0e0e0;
    border: 1px solid #616161;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

#info-button {
    right: 20px;
    font-family: 'Times New Roman', serif;
}
#share-button {
    right: 70px; /* Position next to the info button */
}

#info-button:hover, #share-button:hover {
    background-color: #3a3a3a;
    transform: scale(1.1);
}

#info-modal-overlay, #share-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 3000;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

#info-modal-content, #share-modal-content {
    background-color: #2a2a2a;
    padding: 2rem 3rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    position: relative;
    color: #e0e0e0;
    line-height: 1.6;
}

#close-modal-button, #close-share-modal-button {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 2.5rem;
    color: #aaa;
    cursor: pointer;
    transition: color 0.2s ease;
}

#close-modal-button:hover, #close-share-modal-button:hover {
    color: #fff;
}

#info-modal-content h2, #info-modal-content h4, #share-modal-content h2 {
    margin-top: 0;
    border-bottom: 1px solid #444;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}
#info-modal-content h4 {
    margin-top: 1.5rem;
}

#info-modal-content ul {
    padding-left: 20px;
}

#info-modal-content ul ul {
    padding-left: 25px;
    list-style-type: circle;
}

#info-modal-content li {
    margin-bottom: 0.5rem;
}

/* Styles for Share Modal */
.share-link-container {
    display: flex;
    margin: 1.5rem 0;
}
#share-link-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #444;
    border-radius: 4px 0 0 4px;
    background-color: #333;
    color: #e0e0e0;
    font-family: monospace;
    font-size: 1rem;
}
#copy-link-button {
    padding: 10px 15px;
    border: none;
    background-color: #80c0ff;
    color: #121212;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    transition: background-color 0.2s;
}
#copy-link-button:hover {
    background-color: #6a9bdc;
}
#copy-link-message {
    min-height: 1.2em;
    font-weight: bold;
    color: #4CAF50;
}
#save-error-message {
    min-height: 1.2em;
    font-weight: bold;
    color: #f44336;
}

#save-and-get-link-button {
    background-color: #4CAF50;
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
    width: 100%;
    margin-top: 1rem;
}

#save-and-get-link-button:hover {
    background-color: #45a049;
}