:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --bg-app: #f3f4f6;
    --sidebar-width: 380px;
    --border: #e5e7eb;
    --text: #374151;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', 'Segoe UI', sans-serif; }

body { height: 100vh; background: var(--bg-app); overflow: hidden; }

.app-container { display: flex; height: 100%; }

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: 4px 0 15px rgba(0,0,0,0.03);
}

.header {
    padding: 20px;
    background: #111827;
    color: #fff;
}
.header h2 { font-size: 1.2rem; font-weight: 600; }

/* TABS */
.tabs {
    display: flex;
    background: #f9fafb;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    padding: 15px 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-btn:hover { background: #e5e7eb; }
.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: #fff;
}

/* CONTROLS SCROLL AREA */
.controls-wrapper {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}

.data-form { display: none; }
.data-form.active { display: block; animation: fadeIn 0.3s; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* INPUTS */
.control-group { margin-bottom: 15px; }
.control-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

input[type="text"], input[type="email"], input[type="tel"], textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea { min-height: 80px; resize: vertical; }

.dual-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* NEW FEATURE: INPUT WITH ACTION BUTTON */
.input-with-action {
    display: flex;
    gap: 8px;
}
.input-with-action input {
    flex-grow: 1;
}

.btn-action {
    padding: 10px 14px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.disabled-btn {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    border-color: #e5e7eb;
}

/* TOOLTIP STYLES */
.tooltip-container {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.tooltip-text {
    visibility: hidden;
    width: 240px;
    background-color: #111827;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 12px;
    position: absolute;

    /* Gwarancja bycia na samym wierzchu */
    z-index: 9999;

    /* Pozycjonowanie w dół */
    top: 130%;

    /* Rozwijanie do lewej strony, aby nie wychodził poza suwak */
    right: 0;
    left: auto;

    opacity: 0;
    transform: translateY(0);
    transition: opacity 0.3s, transform 0.3s;
    font-size: 0.8rem;
    line-height: 1.5;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    font-weight: 400;
}

.tooltip-text strong {
    color: #60a5fa;
}

/* Strzałka w górę */
.tooltip-text::after {
    content: "";
    position: absolute;
    bottom: 100%;

    /* Przesunięcie strzałki, aby precyzyjnie celowała w przycisk */
    right: 40px;
    left: auto;

    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent #111827 transparent;
}

.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
    transform: translateY(5px);
}

/* CHECKBOX & COLORS */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}
.checkbox-group input { width: auto; }
.checkbox-group label { margin: 0; cursor: pointer; }

input[type="color"] {
    width: 100%;
    height: 40px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}

/* SEPARATORS */
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
h3 { font-size: 1rem; margin-bottom: 15px; color: #111827; }

/* BUTTONS */
.btn-group { display: flex; gap: 10px; margin-top: 20px; }
.btn-primary {
    flex: 1;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    padding: 6px 12px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}

.footer-spacer { height: 40px; }

/* PREVIEW AREA */
.preview-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-image:
        linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
        linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.canvas-wrapper {
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.1);
    border: 1px solid rgba(0,0,0,0.05);
}

.preview-info { margin-top: 20px; color: #6b7280; font-size: 0.9rem; }

/* Responsywność */
@media (max-width: 800px) {
    .app-container { flex-direction: column; height: auto; }
    .sidebar { width: 100%; height: auto; }
    .preview-area { padding: 50px 20px; min-height: 400px; }
    body { overflow: auto; }
}
