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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: white;
    overflow: hidden;
    color: #2d3748;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.back-btn {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 16px;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.toolbar {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.tool-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tool-section-title {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tool-group {
    display: flex;
    background: white;
    border-radius: 12px;
    padding: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.tool-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    position: relative;
}

.tool-btn:hover {
    background: #f1f5f9;
    transform: translateY(-1px);
}

.tool-btn.active {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.tool-btn::after {
    content: attr(title);
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100;
}

.tool-btn:hover::after {
    opacity: 1;
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    background: white;
    padding: 8px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.color-box {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    position: relative;
}

.color-box:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.color-box.active {
    border-color: #4f46e5;
    transform: scale(1.1);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-label {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.slider {
    -webkit-appearance: none;
    width: 100px;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.size-display {
    font-weight: 600;
    color: #4f46e5;
    min-width: 32px;
}

.canvas-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.canvas-input {
    width: 80px;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    background: #f8fafc;
}

.canvas-input:focus {
    outline: none;
    border-color: #4f46e5;
    background: white;
}

.apply-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.apply-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.canvas-area {
    flex: 1;
    background: #f1f5f9;
    padding: 24px;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    position: relative;
    border: 1px solid #e2e8f0;
}

#canvas {
    display: block;
    cursor: none;
    background: white;
    border-radius: 12px;
}

.brush-cursor {
    position: absolute;
    border: 2px solid #4f46e5;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1000;
    transform: translate(-50%, -50%);
    transition: width 0.1s ease, height 0.1s ease;
    background: rgba(79, 70, 229, 0.1);
    display: none;
}

.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.2s;
}

.canvas-container:hover .resize-handle {
    opacity: 1;
}

.resize-handle.bottom-right {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

.resize-handle.bottom-left {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.resize-handle.top-right {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.resize-handle.top-left {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.resize-handle.bottom {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.resize-handle.right {
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: e-resize;
}

.resize-handle.top {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.resize-handle.left {
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: w-resize;
}

.header-at-bottom {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.status-bar {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #64748b;
}

.coordinates {
    font-family: 'Monaco', 'Menlo', monospace;
    background: white;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

#fileInput {
    display: none;
}

.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    min-width: 160px;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s;
    z-index: 1000;
}

.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-item:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    transform: translateX(2px);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.zoom-display {
    font-weight: 600;
    font-size: 13px;
    color: #4f46e5;
    min-width: 42px;
    text-align: center;
    font-family: 'Monaco', 'Menlo', monospace;
}

.zoom-info {
    font-family: 'Monaco', 'Menlo', monospace;
    background: white;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    font-size: 12px;
    color: #64748b;
}

.app-container {
    animation: fadeIn 0.5s ease-out;
}

/* Text tool controls */
.text-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.font-select {
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    background: #f8fafc;
    cursor: pointer;
    min-width: 120px;
}

.font-select:focus {
    outline: none;
    border-color: #4f46e5;
    background: white;
}

.font-size-input {
    width: 56px;
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    background: #f8fafc;
}

.font-size-input:focus {
    outline: none;
    border-color: #4f46e5;
    background: white;
}

.text-style-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
    color: #374151;
}

.text-style-btn:hover {
    background: #f1f5f9;
}

.text-style-btn.active {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border-color: transparent;
}

/* Text input overlay */
.text-input-overlay {
    position: fixed;
    z-index: 500;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
}

.text-drag-handle {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 6px 6px 0 0;
    cursor: grab;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    width: fit-content;
    min-width: 60px;
}

.text-drag-handle:active {
    cursor: grabbing;
}

.text-input-overlay textarea {
    background: transparent;
    border: 2px dashed #4f46e5;
    border-radius: 4px;
    outline: none;
    resize: both;
    min-width: 60px;
    min-height: 1.4em;
    padding: 4px 6px;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    color: inherit;
    line-height: 1.2;
}