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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    background: linear-gradient(135deg, #fef3f5 0%, #f3e8ff 100%);
}

#container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

#sidebar {
    width: 320px;
    background: white;
    box-shadow: 2px 0 20px rgba(0,0,0,0.1);
    padding: 24px;
    overflow-y: auto;
    z-index: 10;
    flex-shrink: 0;
}

#canvas-container {
    flex: 1;
    position: relative;
}

#canvas-container canvas {
    display: block;
}

/* ============================================ */
/* PRZYCISK POWROTU DO STRONY GŁÓWNEJ          */
/* ============================================ */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    margin-bottom: 16px;
    padding: 8px 12px;
    border-radius: 8px;
    background: #f3f4f6;
    transition: all 0.2s ease;
}

.back-link:hover {
    background: #e5e7eb;
    color: #374151;
}

h1 {
    font-size: 28px;
    font-weight: bold;
    color: #7c3aed;
    margin-bottom: 8px;
}

.subtitle {
    color: #6b7280;
    margin-bottom: 24px;
}

.counter-section {
    margin-bottom: 24px;
}

.counter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.counter-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #374151;
}

.counter-badge {
    background: #f3e8ff;
    color: #7c3aed;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 500;
}

.available-text {
    font-size: 12px;
    color: #6b7280;
}

.section {
    margin-bottom: 24px;
}

.section h3 {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
}

.flower-button {
    display: none;
}

.flower-item-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    transition: border-color 0.2s;
}

.flower-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.flower-color {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.flower-name {
    flex: 1;
    font-weight: 500;
    color: #374151;
    text-align: left;
}

.flower-action-button {
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.btn-add-one {
    background: #e9d5ff;
    color: #7c3aed;
}

.btn-add-one:hover:not(:disabled) {
    background: #d8b4fe;
}

.btn-add-bouquet {
    background: #4f46e5;
    color: white;
    font-size: 16px;
}

.btn-add-bouquet:hover:not(:disabled) {
    background: #4338ca;
}

.flower-action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    margin-bottom: 8px;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-remove {
    background: #f97316;
    color: white;
}

.btn-remove:hover:not(:disabled) {
    background: #ea580c;
}

.btn-clear {
    background: #ef4444;
    color: white;
}

.btn-clear:hover:not(:disabled) {
    background: #dc2626;
}

.btn-qr {
    background: #10b981;
    color: white;
}

.btn-qr:hover:not(:disabled) {
    background: #059669;
}

.controls-overlay {
    position: fixed;
    top: 24px;
    right: 24px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 5;
}

.controls-overlay p {
    font-size: 14px;
    color: #374151;
    margin: 0;
}

.controls-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.control-item {
    font-size: 12px;
    color: #6b7280;
}

/* ============================================ */
/* EDYTOR KWIATU - W SIDEBARZE */
/* ============================================ */
#flower-editor {
    /* Nie ma pozycji fixed - jest w normalnym flow sidebara */
}

#flower-editor.visible {
    display: block;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.editor-header h2 {
    margin: 0;
    color: #7c3aed;
    font-size: 1.5em;
}

.close-btn {
    background: #ff4444;
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #cc0000;
    transform: rotate(90deg);
}

.editor-content h3 {
    color: #555;
    margin-bottom: 10px;
    margin-top: 0;
    font-size: 14px;
}

.editor-hint {
    font-size: 12px;
    color: #888;
    margin-bottom: 12px;
    font-style: italic;
}

/* ============================================ */
/* PRZYCISKI TRYBU EDYCJI */
/* ============================================ */
.edit-mode-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.edit-mode-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px 8px;
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.edit-mode-btn:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
    transform: translateY(-2px);
}

.edit-mode-btn.active {
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
    border-color: #7c3aed;
    color: white;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.edit-mode-icon {
    font-size: 24px;
}

.edit-mode-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Legenda osi */
.axis-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 8px;
    background: #f9fafb;
    border-radius: 6px;
    margin-top: 8px;
}

.axis-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    color: white;
}

.axis-x {
    background: #ff4444;
}

.axis-y {
    background: #44ff44;
    color: #333;
}

.axis-z {
    background: #4444ff;
}

#flower-replace-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.editor-flower-button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.editor-flower-button:hover {
    background: #f3f4f6;
    border-color: #7c3aed;
    transform: translateX(5px);
}

.editor-flower-color {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #ddd;
    flex-shrink: 0;
}

.editor-flower-button span {
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

.editor-section {
    margin-bottom: 20px;
}

.delete-flower-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #ff4444, #cc0000);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(255, 68, 68, 0.3);
}

.delete-flower-btn:hover {
    background: linear-gradient(135deg, #ff0000, #aa0000);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 68, 68, 0.4);
}

.delete-flower-btn:active {
    transform: translateY(0);
}

/* Modal QR */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    max-width: 90%;
    width: 350px;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#qr-code-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

#qr-code-container img {
    border: 8px solid white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: 8px;
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* ============================================ */
/* MODAL QR - DODATKOWE STYLE                  */
/* ============================================ */

.qr-info-box {
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 16px;
    text-align: left;
}

.qr-info-box p {
    margin: 0;
    font-size: 13px;
    color: #166534;
    line-height: 1.5;
}

.qr-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.btn-download {
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
    color: white;
}

.btn-download:hover {
    background: linear-gradient(135deg, #6d28d9 0%, #4f46e5 100%);
}

/* ============================================ */
/* ZAWARTOŚĆ BUKIETU - STAŁA WYSOKOŚĆ          */
/* ============================================ */

#bouquet-contents-section {
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    border: 1px solid #bbf7d0;
    max-height: 160px;
    display: block;
    overflow: hidden;
}

#bouquet-contents-section h3 {
    color: #166534;
    margin-bottom: 12px;
    font-size: 15px;
}

/* Wrapper dla listy i komunikatu */
.bouquet-contents-wrapper {
    max-height: 95px;
    overflow-y: auto;
    overflow-x: hidden;
}

#bouquet-contents-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Komunikat o pustym bukiecie */
.empty-bouquet-message {
    color: #6b7280;
    font-size: 13px;
    text-align: center;
    padding: 12px 8px;
    font-style: italic;
    margin: 0;
}

/* Stylowanie scrollbara dla listy zawartości */
.bouquet-contents-wrapper::-webkit-scrollbar {
    width: 6px;
}

.bouquet-contents-wrapper::-webkit-scrollbar-track {
    background: #d1fae5;
    border-radius: 3px;
}

.bouquet-contents-wrapper::-webkit-scrollbar-thumb {
    background: #22c55e;
    border-radius: 3px;
}

.bouquet-contents-wrapper::-webkit-scrollbar-thumb:hover {
    background: #16a34a;
}

.bouquet-content-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.bouquet-content-color {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.bouquet-content-name {
    flex: 1;
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

.bouquet-content-count {
    font-weight: 600;
    color: #7c3aed;
    font-size: 14px;
    background: #f3e8ff;
    padding: 2px 8px;
    border-radius: 12px;
}

/* ============================================ */
/* RESPONSYWNOŚĆ - TABLETY */
/* ============================================ */
@media (max-width: 1024px) {
    #sidebar {
        width: 280px;
        padding: 20px;
    }

    h1 {
        font-size: 24px;
    }

    .controls-overlay {
        top: 16px;
        right: 16px;
        padding: 10px 12px;
    }

    #bouquet-contents-section {
        max-height: 150px;
    }

    .bouquet-contents-wrapper {
        max-height: 90px;
    }
}

/* ============================================ */
/* RESPONSYWNOŚĆ - TELEFONY */
/* ============================================ */
@media (max-width: 768px) {
    body {
        overflow: auto;
    }

    #container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    #sidebar {
        width: 100%;
        order: 2;
        padding: 16px;
        box-shadow: 0 -2px 20px rgba(0,0,0,0.1);
        max-height: none;
    }

    #canvas-container {
        order: 1;
        width: 100%;
        height: 50vh;
        min-height: 300px;
        flex: none;
    }

    /* Przycisk powrotu na mobile */
    .back-link {
        font-size: 13px;
        padding: 6px 10px;
        margin-bottom: 12px;
    }

    h1 {
        font-size: 22px;
        text-align: center;
    }

    .counter-section {
        margin-bottom: 16px;
    }

    .counter-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .counter-header h2 {
        font-size: 16px;
    }

    .section {
        margin-bottom: 16px;
    }

    .section h3 {
        font-size: 14px;
        margin-bottom: 8px;
    }

    /* Zawartość bukietu na mobile */
    #bouquet-contents-section {
        padding: 12px;
        margin-bottom: 16px;
        max-height: 140px;
    }

    .bouquet-contents-wrapper {
        max-height: 80px;
    }

    #bouquet-contents-list {
        gap: 6px;
    }

    .bouquet-content-item {
        padding: 6px 10px;
        gap: 6px;
    }

    .bouquet-content-color {
        width: 20px;
        height: 20px;
    }

    .bouquet-content-name {
        font-size: 12px;
    }

    .bouquet-content-count {
        font-size: 12px;
        padding: 1px 6px;
    }

    .empty-bouquet-message {
        font-size: 12px;
        padding: 8px;
    }

    /* Lista kwiatów - kompaktowy widok */
    #flowers-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .flower-item-container {
        flex-direction: column;
        padding: 10px;
        gap: 8px;
        margin-bottom: 0;
    }

    .flower-info {
        width: 100%;
        justify-content: center;
        gap: 8px;
    }

    .flower-color {
        width: 24px;
        height: 24px;
    }

    .flower-name {
        font-size: 13px;
        text-align: center;
    }

    .flower-action-button {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .flower-item-container {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }

    .flower-item-container > .flower-info {
        width: 100%;
        margin-bottom: 4px;
    }

    .flower-item-container > .btn-add-one,
    .flower-item-container > .btn-add-bouquet {
        flex: 1;
        max-width: 60px;
    }

    .action-button {
        padding: 14px;
        font-size: 14px;
    }

    .controls-overlay {
        position: fixed;
        top: auto;
        bottom: 52vh;
        right: 8px;
        left: auto;
        padding: 8px 12px;
        font-size: 11px;
        max-width: 140px;
        background: rgba(255, 255, 255, 0.95);
    }

    .controls-overlay .controls-title {
        font-size: 12px;
        margin-bottom: 2px;
    }

    .controls-overlay .control-item {
        font-size: 10px;
        line-height: 1.3;
    }

    /* Edytor na mobile - w sidebarze */
    .editor-header h2 {
        font-size: 1.3em;
    }

    .close-btn {
        width: 40px;
        height: 40px;
    }

    .edit-mode-buttons {
        gap: 6px;
    }

    .edit-mode-btn {
        padding: 10px 6px;
    }

    .edit-mode-icon {
        font-size: 20px;
    }

    .edit-mode-label {
        font-size: 10px;
    }

    .axis-legend {
        gap: 12px;
        padding: 6px;
    }

    .axis-item {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }

    #flower-replace-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .editor-flower-button {
        padding: 10px;
        gap: 8px;
    }

    .editor-flower-button:hover {
        transform: none;
    }

    .editor-flower-color {
        width: 24px;
        height: 24px;
    }

    .editor-flower-button span {
        font-size: 13px;
    }

    .modal-content {
        width: 90%;
        max-width: 320px;
        padding: 20px;
    }

    #qr-code-container img {
        max-width: 200px;
        height: auto;
    }

    .qr-info-box {
        padding: 10px 12px;
    }

    .qr-info-box p {
        font-size: 12px;
    }
}

/* ============================================ */
/* RESPONSYWNOŚĆ - MAŁE TELEFONY */
/* ============================================ */
@media (max-width: 375px) {
    #sidebar {
        padding: 12px;
    }

    .back-link {
        font-size: 12px;
        padding: 5px 8px;
    }

    h1 {
        font-size: 20px;
    }

    .counter-badge {
        padding: 3px 8px;
        font-size: 12px;
    }

    #bouquet-contents-section {
        max-height: 120px;
        padding: 10px;
    }

    .bouquet-contents-wrapper {
        max-height: 70px;
    }

    .empty-bouquet-message {
        font-size: 11px;
    }

    #flowers-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .flower-item-container {
        padding: 8px;
    }

    .flower-color {
        width: 20px;
        height: 20px;
    }

    .flower-name {
        font-size: 12px;
    }

    .flower-action-button {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .action-button {
        padding: 12px;
        font-size: 13px;
    }

    .controls-overlay {
        display: none;
    }

    #flower-replace-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .edit-mode-btn {
        padding: 8px 4px;
    }

    .edit-mode-icon {
        font-size: 18px;
    }

    .edit-mode-label {
        font-size: 9px;
    }
}

/* ============================================ */
/* ORIENTACJA POZIOMA NA TELEFONIE */
/* ============================================ */
@media (max-width: 768px) and (orientation: landscape) {
    #container {
        flex-direction: row;
        height: 100vh;
    }

    #sidebar {
        width: 50%;
        order: 1;
        max-height: 100vh;
        overflow-y: auto;
    }

    #canvas-container {
        order: 2;
        width: 50%;
        height: 100vh;
    }

    #bouquet-contents-section {
        max-height: 120px;
    }

    .bouquet-contents-wrapper {
        max-height: 70px;
    }

    #flowers-list {
        grid-template-columns: repeat(2, 1fr);
    }

    .controls-overlay {
        position: absolute;
        bottom: auto;
        top: 8px;
        right: 8px;
    }

    .edit-mode-buttons {
        gap: 4px;
    }

    .edit-mode-btn {
        padding: 8px 4px;
    }

    .edit-mode-icon {
        font-size: 16px;
    }

    .edit-mode-label {
        font-size: 9px;
    }

    #flower-replace-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .editor-flower-button {
        padding: 8px;
        gap: 6px;
    }

    .editor-flower-color {
        width: 20px;
        height: 20px;
    }

    .editor-flower-button span {
        font-size: 12px;
    }
}

/* ============================================ */
/* REDUKCJA RUCHU */
/* ============================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* ============================================ */
/* TOUCH-FRIENDLY IMPROVEMENTS */
/* ============================================ */
@media (hover: none) and (pointer: coarse) {
    .flower-action-button {
        min-width: 44px;
        min-height: 44px;
    }

    .action-button {
        min-height: 48px;
    }

    .editor-flower-button {
        min-height: 48px;
    }

    .close-btn {
        width: 44px;
        height: 44px;
    }

    .edit-mode-btn {
        min-height: 60px;
    }

    .back-link {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}