/* Profithome Dashboard — Wycena Skupowa */

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

:root {
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --border: #e2e8f0;
    --border-focus: #FFB603;
    --text: #1a1a1a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #FFB603;
    --accent-hover: #e6a300;
    --accent-text: #071658;
    --accent-light: #fffbeb;
    --navy: #071658;
    --navy-dark: #050f3d;
    --navy-light: #0c2275;
    --green: #16a34a;
    --green-light: #f0fdf4;
    --red: #dc2626;
    --red-light: #fef2f2;
    --orange: #ea580c;
    --orange-light: #fff7ed;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Header */
.dashboard-header {
    background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 40%, var(--navy-light) 100%);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.dashboard-header .header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.dashboard-header .header-logo {
    height: 28px;
    width: auto;
}

.dashboard-header h1 {
    font-size: 1rem;
    font-weight: 600;
    color: rgba(255,255,255,0.7);
}

.dashboard-header h1 span {
    color: var(--accent);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-badge {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.1);
    padding: 4px 10px;
    border-radius: 12px;
}

.header-counter {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
}

.btn-logout {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-logout:hover {
    color: #fff;
    border-color: rgba(255,255,255,0.3);
}

/* Layout */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: calc(100vh - 49px);
}

@media (max-width: 1024px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
}

/* Panels */
.panel-form {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(100vh - 49px);
    border-right: 1px solid var(--border);
}

.panel-results {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(100vh - 49px);
    background: var(--bg);
}

@media (max-width: 1024px) {
    .panel-form, .panel-results {
        max-height: none;
        border-right: none;
    }
}

/* Sections */
.form-section {
    margin-bottom: 24px;
}

.form-section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* Form Groups */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.form-row-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Inputs */
input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.875rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
    height: 42px;
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.5 4.5L6 8L9.5 4.5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 182, 3, 0.15);
}

input::placeholder { color: var(--text-muted); }

/* Custom Select (City) */
.custom-select-wrapper {
    position: relative;
}

.custom-select-input {
    padding-right: 32px !important;
    cursor: pointer;
}

.custom-select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition: transform 0.2s;
}

.custom-select-wrapper.open .custom-select-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 240px;
    overflow-y: auto;
    z-index: 60;
    display: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 4px;
}

.custom-select-wrapper.open .custom-select-dropdown {
    display: block;
    animation: dropdownFadeIn 0.15s ease-out;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.custom-select-option {
    padding: 8px 12px;
    font-size: 0.8125rem;
    cursor: pointer;
    border-radius: 6px;
    color: var(--text);
    transition: background 0.1s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-select-option:hover,
.custom-select-option.highlighted {
    background: var(--accent-light);
}

.custom-select-option.selected {
    background: var(--accent-light);
    color: var(--accent-text);
    font-weight: 600;
}

.custom-select-option.selected::after {
    content: '✓';
    margin-left: auto;
    color: var(--accent);
    font-weight: 700;
}

.custom-select-no-results {
    padding: 12px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-align: center;
}

/* Autocomplete */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 50;
    display: none;
    box-shadow: var(--shadow-lg);
}

.autocomplete-suggestions.active { display: block; }

.autocomplete-item {
    padding: 8px 12px;
    font-size: 0.8125rem;
    cursor: pointer;
    border-bottom: 1px solid var(--bg);
}

.autocomplete-item:hover { background: var(--accent-light); }

/* Corrections Grid */
.corrections-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

@media (max-width: 600px) {
    .corrections-grid { grid-template-columns: 1fr; }
}

.correction-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.correction-item label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.correction-item select {
    padding: 6px 8px;
    font-size: 0.8125rem;
    height: 36px;
}

/* Submit Button */
.btn-calculate {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-calculate:hover { background: var(--accent-hover); }
.btn-calculate:active { transform: scale(0.99); }
.btn-calculate:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-calculate.loading {
    position: relative;
    color: transparent;
}

.btn-calculate.loading::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Results Panel */
.results-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--text-muted);
    text-align: center;
    gap: 12px;
}

.results-placeholder svg {
    opacity: 0.3;
}

/* Result Cards */
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.result-card-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

/* Main Price Card */
.price-card {
    background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 40%, var(--navy-light) 100%);
    border: none;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    text-align: center;
}

.price-card .price-label {
    font-size: 0.8125rem;
    color: rgba(255,255,255,0.7);
    margin-bottom: 4px;
}

.price-card .price-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.price-card .price-sub {
    font-size: 0.875rem;
    color: rgba(255,255,255,0.5);
    margin-top: 4px;
}

/* Price Grid */
.price-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.price-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
}

.price-box .label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.price-box .value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text);
}

.price-box.highlight {
    border-color: var(--green);
    background: var(--green-light);
}

.price-box.highlight .value {
    color: var(--green);
}

.price-box.warning {
    border-color: var(--orange);
    background: var(--orange-light);
}

.price-box.warning .value {
    color: var(--orange);
}

/* Corrections Table */
.corrections-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.corrections-table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 6px 8px;
    border-bottom: 2px solid var(--border);
    font-size: 0.75rem;
}

.corrections-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--bg);
}

.corrections-table tr:hover td {
    background: var(--accent-light);
}

.correction-positive { color: var(--green); font-weight: 600; }
.correction-negative { color: var(--red); font-weight: 600; }
.correction-zero { color: var(--text-muted); }

.corrections-table .total-row td {
    font-weight: 700;
    border-top: 2px solid var(--border);
    border-bottom: none;
}

/* TOP 5 */
.top5-list {
    list-style: none;
}

.top5-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--bg);
}

.top5-rank {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    flex-shrink: 0;
}

.top5-name { flex: 1; font-size: 0.8125rem; }

.top5-value {
    font-weight: 600;
    font-size: 0.8125rem;
}

/* Similar Offers */
.offers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

@media (max-width: 600px) {
    .offers-grid { grid-template-columns: 1fr; }
}

.offer-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    font-size: 0.8125rem;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.2s;
    display: block;
}

.offer-card:hover { border-color: var(--accent); }

.offer-card .offer-price {
    font-weight: 700;
    font-size: 0.9375rem;
    margin-bottom: 2px;
}

.offer-card .offer-price-m2 {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.offer-card .offer-details {
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Report Textarea */
.report-box {
    position: relative;
}

.report-textarea {
    width: 100%;
    min-height: 220px;
    padding: 12px;
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    resize: vertical;
}

.btn-copy {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-copy:hover { background: var(--navy-light); }
.btn-copy.copied { background: var(--green); }

/* Error */
.error-msg {
    background: var(--red-light);
    border: 1px solid var(--red);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--red);
    font-size: 0.8125rem;
    margin-bottom: 12px;
    display: none;
}

.error-msg.active { display: block; }

/* Responsive form rows */
@media (max-width: 600px) {
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .price-grid { grid-template-columns: 1fr; }
    .panel-form, .panel-results { padding: 16px; }
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 40%, var(--navy-light) 100%);
}

.login-box {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    text-align: center;
}

.login-box .login-logo {
    height: 36px;
    margin-bottom: 8px;
}

.login-box .login-title {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 28px;
}

.login-box .form-group {
    text-align: left;
    margin-bottom: 16px;
}

.login-box .form-group label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.login-box input[type="text"],
.login-box input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.875rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    transition: border-color 0.2s;
}

.login-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 182, 3, 0.15);
}

.btn-login {
    width: 100%;
    padding: 12px;
    font-size: 0.9375rem;
    font-weight: 700;
    font-family: inherit;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s;
}

.btn-login:hover { background: var(--accent-hover); }

.login-error {
    color: var(--red);
    font-size: 0.8125rem;
    margin-top: 12px;
    display: none;
}

.login-error.active { display: block; }

/* Hide dashboard when not logged in */
.app-content { display: none; }
.app-content.authenticated { display: block; }
