/* Import modern fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* CSS Variables for consistent theming */
:root {
    --primary-color: #dc2626; /* Red Crow brand color */
    --primary-hover: #b91c1c;
    --secondary-color: #667eea;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--gray-50);
    color: var(--gray-800);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

header {
    position: relative;
    text-align: center;
    padding: 24px 20px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

/* Constrain header content to the same width as main container */
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

header h1 {
    font-family: 'Inter', sans-serif;
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
    letter-spacing: -0.025em;
}

footer {
    text-align: center;
    padding: 20px;
    background: white;
    border-top: 1px solid var(--gray-200);
    margin-top: 40px;
    color: var(--gray-600);
}

.header-right {
    position: absolute;
    top: 8px; /* move up a bit */
    right: 0; /* align with container right edge */
    display: flex;
    flex-direction: column; /* vertical layout */
    align-items: flex-end;
    gap: 8px;
}

.header-buttons {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

/* YouTube link under title */
.youtube-link {
    text-align: center;
    font-size: 1.5rem; /* match previous ~66% of h1 */
    margin-top: 6px;
    font-family: 'Nanum Gothic', sans-serif;
}
.youtube-link a { text-decoration: none; }
.youtube-link .yt-host { color: #111827; }
.youtube-link .yt-handle { color: #b71c1c; }

.visitor-counter {
    background-color: var(--gray-100);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    box-shadow: var(--shadow-sm);
}

/* 2x2 layout for colon alignment */
.visitor-counter.two-by-two {
    display: grid;
    grid-template-columns: max-content max-content;
    column-gap: 8px;
    row-gap: 2px;
    align-items: center;
}
.visitor-counter.two-by-two .label-cell {
    justify-self: end;
    text-align: right;
    white-space: nowrap;
}
.visitor-counter.two-by-two .value-cell {
    justify-self: center;
    text-align: center;
    color: var(--gray-800);
    font-variant-numeric: tabular-nums;
}

.login-button, .logout-button, .admin-button {
    text-decoration: none;
    background-color: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.admin-button {
    background-color: var(--warning-color);
    margin-right: 8px;
}

.login-button:hover, .logout-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.admin-button:hover {
    background-color: #d97706;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.login-links {
    text-align: center;
    margin-top: 15px;
    font-size: 0.9em;
}

.login-links a {
    color: #3498db;
    text-decoration: none;
    margin: 0 5px;
}

.login-links a:hover {
    text-decoration: underline;
}

.social-login {
    margin-top: 20px;
    text-align: center;
}

.google-login-button {
    background-color: #ffffff;
    color: #757575;
    border: 1px solid #ddd;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    font-size: 1em;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.google-login-button img {
    width: 18px;
    height: 18px;
    margin-right: 10px;
}

.google-login-button:hover {
    background-color: #f5f5f5;
}

.logout-button {
    text-decoration: none;
    background-color: #e74c3c;
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    font-size: 0.9em;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 20px;
}

.login-container {
    width: 300px;
    margin: 100px auto;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
}

.input-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

button {
    width: 100%;
    padding: 10px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

button:hover {
    background-color: #2980b9;
}

/* Small button style in filter panel */
.small-btn {
    display: inline-block;
    width: auto;
    padding: 6px 10px;
    font-size: 0.9em;
    border-radius: 4px;
    background-color: #3498db;
    color: #fff;
    border: none;
    cursor: pointer;
    margin-left: 6px;
}
.small-btn:hover { background-color: #2980b9; }

/* Disabled states: no hover/click effect */
button[disabled], .small-btn[disabled], .google-login-button[disabled] {
    background-color: #cfcfcf !important;
    color: #777 !important;
    border-color: #bdbdbd !important;
    opacity: 1 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

/* Ensure no hover color change when disabled */
button[disabled]:hover, .small-btn[disabled]:hover, .google-login-button[disabled]:hover {
    background-color: #cfcfcf !important;
    color: #777 !important;
    border-color: #bdbdbd !important;
}

.market-selector {
    text-align: center;
    margin-bottom: 32px;
}

.market-carousel {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.market-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 0 20px;
    cursor: grab;
    touch-action: pan-y;
}

.market-strip:active {
    cursor: grabbing;
}

.market-card {
    background: white;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow);
}

.market-card.center-card {
    width: 240px; /* slightly narrower */
    height: 180px; /* taller to enlarge image */
    opacity: 1;
    transform: scale(1);
    z-index: 3;
    box-shadow: var(--shadow-lg);
}

.market-card.side-card {
    width: 180px; /* slightly narrower */
    height: 130px; /* taller to enlarge image */
    opacity: 0.6;
    transform: scale(0.85);
    z-index: 1;
}

.market-card.side-card:hover {
    opacity: 0.8;
    transform: scale(0.9);
}

.market-flag {
    flex: 1;
    width: 100%;
    overflow: hidden;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.market-flag img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.market-info {
    padding: 8px 12px;
    background: white;
    text-align: center;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.market-name {
    font-size: 1rem; /* keep current size */
    font-weight: 600;
    color: var(--gray-900);
    /* move title down to where description used to be */
    margin: 6px 0 0 0;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.market-desc {
    display: none; /* remove original description line */
}

.market-nav-btn {
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    color: var(--gray-600);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    margin: 0 16px;
    z-index: 10;
}

.market-nav-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    color: var(--gray-800);
    box-shadow: var(--shadow);
}

.market-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.market-indicators {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray-300);
    cursor: pointer;
    transition: all 0.2s ease;
}

.indicator.active {
    background: var(--secondary-color);
    transform: scale(1.2);
}

/* Summary header with flex layout for title and button */
.summary-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 16px;
}

.portfolio-customize-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    margin: 0 auto;
}

.portfolio-customize-btn.compact {
    padding: 8px 16px;
    font-size: 16px;
    font-weight: 500;
    margin: 0;
    flex-shrink: 0;
    min-width: fit-content;
    width: fit-content;
    gap: 6px;
}

.portfolio-customize-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

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

.filter-badge {
    background-color: #ff4757;
    color: white;
    font-size: 12px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    text-align: center;
}

.summary-section {
    background: white;
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: visible;
    position: relative;
}

.summary-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
    letter-spacing: -0.025em;
    flex-grow: 1;
}

.details-section {
    background: white;
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

#chart-container {
    position: relative;
    height: 400px;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--gray-200);
    background: white;
}

th {
    background-color: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-700);
    letter-spacing: 0.025em;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.875rem;
    color: var(--gray-700);
    text-align: left;
}

thead {
    background-color: var(--gray-50);
}

#summary-table tbody tr, 
#details-table tbody tr {
    transition: all 0.2s ease;
}

#summary-table tbody tr:hover {
    background-color: var(--gray-50);
    cursor: pointer;
}

#summary-table tbody tr.active {
    background-color: rgba(59, 130, 246, 0.05);
    border-left: 3px solid var(--secondary-color);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* 조건부 서식 스타일 */
.highlight-max {
    background-color: var(--warning-color) !important;
    color: white !important;
    font-weight: 600;
}

.profit-green {
    background-color: var(--success-color);
    color: white !important;
    font-weight: 600;
}

.profit-red {
    background-color: var(--error-color);
    color: white !important;
    font-weight: 600;
}

.profit-orange {
    background-color: #f97316;
    color: white !important;
    font-weight: 600;
}

.profit-yellow {
    background-color: #fefce8;
    color: var(--gray-900);
    font-weight: 600;
}

/* Ensure text inside cells also follows row color for conditional backgrounds */
.profit-green td, .profit-green th { color: #ffffff !important; }
.profit-red td, .profit-red th { color: #ffffff !important; }
.profit-orange td, .profit-orange th { color: #ffffff !important; }
.profit-yellow td, .profit-yellow th { color: var(--gray-900) !important; }

.mobile-placeholder {
    text-align: center;
    padding: 50px;
    background: #fff;
    border-radius: 8px;
}

/* Modal for filter load */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: #fff;
    border-radius: 12px;
    padding: 0;
    width: 90%;
    max-width: 900px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: modalFadeIn 0.2s ease-out;
}
.modal-header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 20px 24px;
    border-radius: 12px 12px 0 0;
}
.modal-header h3 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
}
.modal-close { 
    cursor: pointer; 
    font-size: 1.8em; 
    line-height: 1; 
    color: #fff;
    transition: color 0.2s ease;
}
.modal-close:hover { 
    color: #e74c3c; 
}
.filter-modal-description {
    padding: 16px 24px 0;
    text-align: center;
}
.filter-modal-description p {
    margin: 0;
    color: #666;
    font-size: 0.95em;
    line-height: 1.4;
}
.filter-list-grid { 
    display: flex; 
    gap: 16px; 
    padding: 24px;
}
.filter-box { 
    flex: 1; 
    background: linear-gradient(135deg, #f8faff, #f1f7ff); 
    border: 1px solid #d1e7dd; 
    border-radius: 10px; 
    padding: 16px; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.filter-box h4 { 
    margin: 0 0 12px 0; 
    color: #2c3e50;
    font-size: 1.1em;
    font-weight: 600;
    text-align: center;
}
.filter-table { 
    width: 100%; 
    border-collapse: collapse; 
    border-radius: 8px; 
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.filter-table th, .filter-table td { 
    border: 1px solid #e3e8ef; 
    padding: 10px 8px; 
    text-align: center;
}
.filter-table thead { 
    background: linear-gradient(135deg, #4e73df, #3652d1);
    color: white;
}
.filter-table thead th {
    font-weight: 600;
    font-size: 0.9em;
}
.filter-table tbody tr { 
    cursor: pointer; 
    transition: background-color 0.2s ease;
}
.filter-table tbody tr:hover { 
    background: #e3f2fd; 
}
.filter-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}
.filter-table tbody tr:nth-child(even):hover {
    background: #e3f2fd;
}
.delete-btn { 
    background: #dc3545; 
    color: white; 
    border: none; 
    border-radius: 3px; 
    padding: 2px 6px; 
    cursor: pointer; 
    font-size: 12px; 
    font-weight: bold;
}
.delete-btn:hover { 
    background: #c82333; 
}

/* 커스텀 확인 모달 스타일 개선 */
.custom-confirm-content {
    max-width: 450px;
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: modalFadeIn 0.2s ease-out;
}

.custom-confirm-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 24px;
    border-radius: 12px 12px 0 0;
    text-align: center;
}

.custom-confirm-header h3 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
}

.custom-confirm-body {
    padding: 24px;
    text-align: center;
}

.custom-confirm-body p {
    margin: 0;
    line-height: 1.6;
    font-size: 1.1em;
    color: #444;
}

.custom-confirm-buttons {
    padding: 0 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 100px;
}

.btn-primary {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d, #545b62);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #545b62, #495057);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108,117,125,0.3);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 프로그래스 바 스타일 */
.progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(2px);
}

.progress-container {
    background: white;
    border-radius: 12px;
    padding: 30px 40px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: modalFadeIn 0.3s ease-out;
}

.progress-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.spinner-circle {
    width: 50px;
    height: 50px;
    border: 4px solid #e9ecef;
    border-top: 4px solid #007bff;
    border-right: 4px solid #0056b3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

.progress-text {
    margin: 0;
    color: #495057;
    font-size: 1.1em;
    font-weight: 500;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

#summary-table-container {
    max-height: 250px; /* 5 rows + header */
    overflow-y: auto;
}

#details-table-container {
    max-height: 450px; /* 10 rows + header */
    overflow-y: auto;
}

/* Filter UI */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0 12px;
}

/* Ensure filter icon is visible on white background */
button.icon-button {
    width: 36px;
    height: 36px;
    line-height: 36px;
    text-align: center;
    border-radius: 18px;
    border: 1px solid #ddd;
    background: #fff;
    color: #333; /* override global button white text */
    cursor: pointer;
}

button.icon-button:hover {
    background: #f7f7f7;
    color: #333;
}

.icon-button.small {
    width: 28px;
    height: 28px;
    line-height: 28px;
    border-radius: 6px;
    font-size: 14px;
}

.filter-panel {
    display: block;
    background: #fff;
    border: 1px solid #e0e0e0;
    padding: 10px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    position: absolute;
    top: 65px;
    right: 0;
    z-index: 1000;
    max-width: 495px;
    min-width: 380px;
    /* Ensure relative positioning context for validation messages */
}

/* Stronger specificity so desktop icon never appears white */
#filter-toggle {
    color: #333 !important;
}
#filter-toggle:hover {
    color: #333 !important;
}
#filter-toggle svg { display: block; }

.filter-form {
    margin-bottom: 8px;
}

.filter-form-grid {
    display: grid;
    grid-template-columns: 1fr 120px;
    grid-template-rows: auto auto;
    gap: 8px;
    align-items: start;
}

.company-input-container {
    position: relative;
    grid-column: 1;
    grid-row: 1;
}

.filter-date-row {
    display: flex;
    gap: 8px;
    grid-column: 1;
    grid-row: 2;
}

.filter-button-cell {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    grid-column: 2;
}

.filter-button-cell:first-of-type {
    grid-row: 1;
}

.filter-button-cell:last-of-type {
    grid-row: 2;
}

.filter-form input {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#filter-company {
    width: 250px;
    min-width: 200px;
}

.small-btn {
    padding: 6px 10px;
    font-size: 0.9em;
}

.filter-button-cell .small-btn {
    min-width: 70px;
    text-align: center;
}

.small-btn.accent { background-color: #2ecc71; }
.small-btn.danger { background-color: #e74c3c; }

.filter-list-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.filter-panel ul {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 180px;
    overflow-y: auto;
}

.filter-panel li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.filter-chip {
    background: #f5f7fb;
    border: 1px solid #e1e6f0;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.9em;
}

/* 팝업 스타일 */
.popup {
    position: fixed;
    background-color: white;
    border: 1px solid #ccc;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 5px;
    z-index: 1000;
    font-size: 0.9em;
}

.popup-content h3 {
    margin-top: 0;
    font-size: 1.1em;
    color: #333;
}

.popup-content p {
    margin: 5px 0;
}

.close-button {
    position: absolute;
    top: 5px;
    right: 10px;
    font-size: 1.5em;
    cursor: pointer;
    color: #aaa;
}

.close-button:hover {
    color: #333;
}

#popup-table-container {
    max-height: 300px;
    overflow-y: auto;
}

#popup-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

#popup-table th, #popup-table td {
    border: 1px solid #ddd;
    padding: 6px;
    text-align: left;
    font-size: 0.9em;
}

/* Company list dropdown */
.company-list-panel {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    width: 400px;
    max-height: 300px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1001;
    padding: 8px;
}


#company-list-panel ul {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 250px;
    overflow-y: auto;
    border-top: 1px solid #f0f0f0;
}

#company-list-panel li {
    padding: 6px 4px;
    cursor: pointer;
}

#company-list-panel li:hover {
    background: #f5f7fb;
}

/* === RESPONSIVE DESIGN === */
/* Mobile First Approach */

/* Tablet and smaller desktop screens */
@media (max-width: 1024px) {
    .container {
        padding: 20px 16px;
    }
    
    .header-right {
        position: static;
        margin-top: 16px;
        justify-content: center;
    }
    
    header h1 {
        font-size: 1.875rem;
        margin-bottom: 8px;
    }
}

/* Mobile screens */
@media (max-width: 768px) {
    .container {
        padding: 16px 12px;
    }
    
    header {
        padding: 16px 12px;
    }
    
    header h1 {
        font-size: 1.5rem;
        line-height: 1.2;
    }
    
    .header-right {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }
    
    .visitor-counter {
        font-size: 0.75rem;
        padding: 6px 10px;
    }
    
    .market-carousel {
        max-width: 500px;
    }
    
    .market-strip {
        gap: 12px;
        padding: 0 16px;
    }
    
    .market-card.center-card {
        width: 240px;
        height: 140px;
    }
    
    .market-card.side-card {
        width: 160px;
        height: 96px;
    }
    
    .market-info {
        padding: 6px 10px;
    }
    
    .market-name {
        font-size: 0.9375rem;
    }
    
    .market-desc {
        font-size: 0.6875rem;
    }
    
    .market-nav-btn {
        width: 36px;
        height: 36px;
        margin: 0 12px;
        font-size: 16px;
    }
    
    .summary-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .portfolio-customize-btn {
        padding: 14px 24px;
        font-size: 16px;
        width: 100%;
        max-width: 280px;
        margin: 0 auto;
    }
    
    .portfolio-customize-btn.compact {
        padding: 12px 20px;
        font-size: 14px;
        width: 100%;
        max-width: 200px;
    }
    
    .summary-section,
    .details-section {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .summary-title {
        font-size: 1.25rem;
        margin-bottom: 12px;
    }
    
    /* Make tables horizontally scrollable on mobile */
    #summary-table-container,
    #details-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
    
    th, td {
        padding: 10px 12px;
        font-size: 0.8125rem;
        white-space: nowrap;
    }
    
    /* Responsive chart container */
    #chart-container {
        height: 300px;
        margin-bottom: 16px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.25rem;
    }
    
    .market-carousel {
        max-width: 400px;
    }
    
    .market-strip {
        gap: 8px;
        padding: 0 12px;
    }
    
    .market-card.center-card {
        width: 200px;
        height: 120px;
    }
    
    .market-card.side-card {
        width: 120px;
        height: 80px;
    }
    
    .market-info {
        padding: 4px 8px;
    }
    
    .market-name {
        font-size: 0.875rem;
    }
    
    .market-desc {
        font-size: 0.625rem;
    }
    
    .market-nav-btn {
        width: 32px;
        height: 32px;
        margin: 0 8px;
        font-size: 14px;
    }
    
    .portfolio-customize-btn {
        max-width: none;
        width: 100%;
        padding: 16px 20px;
        font-size: 15px;
    }
    
    .portfolio-customize-btn.compact {
        padding: 14px 18px;
        font-size: 13px;
    }
    
    th, td {
        padding: 8px 10px;
        font-size: 0.75rem;
    }
    
    .summary-section,
    .details-section {
        padding: 12px;
        border-radius: var(--radius);
    }
    
    #chart-container {
        height: 250px;
    }
}

/* ============================================================================
   Portfolio Add Button
   ============================================================================ */

.btn-add-to-portfolio {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    font-size: 1.3rem;
    transition: all 0.2s ease;
}

.btn-add-to-portfolio:hover {
    transform: scale(1.15);
    filter: brightness(1.2);
}

.btn-add-to-portfolio.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(1);
}

.btn-add-to-portfolio.disabled:hover {
    background: var(--gray-100);
    color: var(--gray-400);
    transform: none;
    box-shadow: none;
}

/* ============================================================================
   Portfolio Modal Styles
   ============================================================================ */

.modal-medium {
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.stock-info-box {
    background: linear-gradient(135deg, var(--gray-50), var(--gray-100));
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.stock-info-box h4 {
    margin: 0 0 0.5rem 0;
    color: var(--gray-900);
    font-size: 1.2rem;
    font-weight: 600;
}

.stock-info-box p {
    margin: 0.25rem 0;
    color: var(--gray-600);
    font-size: 0.9rem;
}

.stock-info-box .price-info {
    margin-top: 0.75rem;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 1rem;
}

.stock-info-box .price-info span {
    color: var(--secondary-color);
    font-weight: 600;
}

.info-message {
    background: var(--gray-50);
    border: 1px solid var(--gray-300);
    border-left: 4px solid var(--secondary-color);
    padding: 1rem;
    border-radius: var(--radius-sm);
    color: var(--gray-700);
    font-size: 0.9rem;
    line-height: 1.5;
}

.info-message a {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
}

.info-message a:hover {
    text-decoration: underline;
}

.modal-body {
    padding: 1.5rem 2rem;
}

.modal-footer {
    padding: 1rem 2rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
    border: none;
    padding: 0.7rem 1.2rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-primary {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.7rem 1.2rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
    font-weight: 500;
    font-size: 0.9rem;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Mobile responsive for portfolio button */
@media (max-width: 768px) {
    .btn-add-to-portfolio {
        padding: 4px 6px;
        font-size: 1rem;
    }

    .modal-medium {
        max-width: 95%;
    }

    .stock-info-box {
        padding: 0.75rem;
    }

    .stock-info-box h4 {
        font-size: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        flex-direction: column;
    }

    .modal-footer button {
        width: 100%;
    }
}

/* Responsive filter panel */
@media (max-width: 768px) {
    .filter-panel input,
    .filter-panel button {
        margin-bottom: 8px;
    }
    
    .filter-form {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .filter-list-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-bottom: 8px;
    }
    
    .filter-list-actions button {
        flex: 1;
        min-width: 80px;
    }
}

/* Hide mobile placeholder as we're now fully responsive */
.mobile-placeholder {
    display: none;
}
