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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #3a6ea5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    user-select: none;
}

/* Windows XP Style Window - Centered */
.paint-window {
    background: #ece9d8;
    border: 1px solid #0054e3;
    border-radius: 8px 8px 0 0;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 900px;
    height: 70vh;
    max-height: 600px;
    overflow: hidden;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
}

/* Title Bar */
.title-bar {
    background: linear-gradient(180deg,
        #0058ee 0%,
        #3a93ff 8%,
        #288eff 40%,
        #0058ee 88%,
        #004bd6 93%,
        #003db3 95%,
        #003db3 100%);
    color: white;
    padding: 3px 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
}

.title-bar-left {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
}

.window-icon {
    width: 16px;
    height: 16px;
}

.title-bar-buttons {
    display: flex;
    gap: 2px;
}

.title-btn {
    width: 21px;
    height: 21px;
    border: none;
    border-radius: 3px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.title-btn.minimize,
.title-btn.maximize {
    background: linear-gradient(180deg, #3c8cf7 0%, #1665d8 50%, #0a50c8 100%);
    color: white;
    border: 1px solid #0a3c8c;
}

.title-btn.minimize:hover,
.title-btn.maximize:hover {
    background: linear-gradient(180deg, #5ca8ff 0%, #3c8cf7 50%, #1665d8 100%);
}

.title-btn.close {
    background: linear-gradient(180deg, #e87458 0%, #cf4b34 50%, #b33620 100%);
    color: white;
    border: 1px solid #8c2810;
}

.title-btn.close:hover {
    background: linear-gradient(180deg, #ff9070 0%, #e87458 50%, #cf4b34 100%);
}

/* Menu Bar */
.menu-bar {
    background: #ece9d8;
    padding: 2px 5px;
    display: flex;
    border-bottom: 1px solid #adb5b3;
}

.menu-item {
    padding: 3px 8px;
    font-size: 12px;
    cursor: pointer;
    position: relative;
}

.menu-item:hover {
    background: #316ac5;
    color: white;
}

/* Dropdown Menus */
.dropdown-menu {
    display: none;
    position: absolute;
    background: #fff;
    border: 1px solid #adb5b3;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    min-width: 180px;
}

.dropdown-menu.active {
    display: block;
}

.menu-option {
    padding: 5px 30px 5px 25px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-option:hover {
    background: #316ac5;
    color: white;
}

.menu-option .shortcut {
    color: #888;
    font-size: 11px;
    margin-left: 20px;
}

.menu-option:hover .shortcut {
    color: #ddd;
}

.menu-divider {
    height: 1px;
    background: #ccc;
    margin: 3px 0;
}

/* Main Content Area */
.main-content {
    display: flex;
    background: #ece9d8;
    flex: 1;
    overflow: hidden;
}

/* Tool Palette */
.tool-palette {
    background: #ece9d8;
    border-right: 1px solid #808080;
    border-bottom: 1px solid #808080;
    padding: 2px;
    width: 66px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0px;
    background: #ece9d8;
    border: 2px solid;
    border-color: #808080 #fff #fff #808080;
    padding: 2px;
}

.tool-btn {
    width: 26px;
    height: 26px;
    border: 1px solid transparent;
    background: #ece9d8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
}

.tool-btn svg {
    width: 20px;
    height: 20px;
}

.tool-btn:hover {
    border: 1px solid #316ac5;
    background: #c1d2ee;
}

.tool-btn.active {
    border: 1px solid #316ac5;
    background: #b0c4de;
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Tool Option Panels */
.shape-options,
.line-width-options,
.brush-options,
.eraser-options,
.magnifier-options {
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 3px;
    background: #ece9d8;
    border: 2px solid;
    border-color: #808080 #fff #fff #808080;
}

.shape-options.active,
.line-width-options.active,
.brush-options.active,
.eraser-options.active,
.magnifier-options.active {
    display: flex;
}

/* Shape Fill Options */
.shape-option-btn {
    width: 100%;
    height: 22px;
    border: 1px solid transparent;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
}

.shape-option-btn svg {
    width: 40px;
    height: 16px;
}

.shape-option-btn:hover {
    border: 1px solid #316ac5;
    background: #e8f0fd;
}

.shape-option-btn.active {
    border: 1px solid #316ac5;
    background: #c1d2ee;
}

/* Line Width Options */
.line-width-btn {
    width: 100%;
    height: 14px;
    border: 1px solid transparent;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 5px;
}

.line-preview {
    width: 100%;
    background: #000;
}

.line-width-btn:hover {
    border: 1px solid #316ac5;
    background: #e8f0fd;
}

.line-width-btn.active {
    border: 1px solid #316ac5;
    background: #c1d2ee;
}

/* Brush Options */
.brush-options {
    display: none;
    flex-wrap: wrap;
    flex-direction: row;
    justify-content: center;
}

.brush-options.active {
    display: flex;
}

.brush-option-btn {
    width: 26px;
    height: 26px;
    border: 1px solid transparent;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
}

.brush-option-btn svg {
    width: 20px;
    height: 20px;
}

.brush-option-btn:hover {
    border: 1px solid #316ac5;
    background: #e8f0fd;
}

.brush-option-btn.active {
    border: 1px solid #316ac5;
    background: #c1d2ee;
}

/* Eraser Options */
.eraser-options {
    align-items: center;
}

.eraser-option-btn {
    width: 100%;
    height: 20px;
    border: 1px solid transparent;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.eraser-option-btn:hover {
    border: 1px solid #316ac5;
    background: #e8f0fd;
}

.eraser-option-btn.active {
    border: 1px solid #316ac5;
    background: #c1d2ee;
}

/* Magnifier Options */
.magnifier-option-btn {
    width: 100%;
    height: 18px;
    border: 1px solid transparent;
    background: #fff;
    cursor: pointer;
    font-size: 10px;
    font-weight: bold;
}

.magnifier-option-btn:hover {
    border: 1px solid #316ac5;
    background: #e8f0fd;
}

.magnifier-option-btn.active {
    border: 1px solid #316ac5;
    background: #c1d2ee;
}

/* Canvas Area */
.canvas-container {
    flex: 1;
    background: #808080;
    padding: 2px;
    overflow: hidden;
}

.canvas-wrapper {
    display: inline-block;
    position: relative;
    background: #fff;
}

#paint-canvas {
    display: block;
    cursor: crosshair;
    background: #fff;
}

.resize-handle {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 8px;
    height: 8px;
    background: #316ac5;
    cursor: nwse-resize;
    z-index: 10;
}

/* Color Palette */
.color-palette-container {
    background: #ece9d8;
    padding: 3px 5px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #fff;
}

.current-colors {
    display: flex;
    align-items: center;
}

.color-box-wrapper {
    position: relative;
    width: 30px;
    height: 30px;
}

.background-color {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 18px;
    height: 18px;
    background: #fff;
    border: 1px solid #808080;
    cursor: pointer;
}

.foreground-color {
    position: absolute;
    left: 0;
    top: 0;
    width: 18px;
    height: 18px;
    background: #000;
    border: 1px solid #808080;
    z-index: 1;
    cursor: pointer;
}

.color-palette {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.color-row {
    display: flex;
    gap: 1px;
}

.color-swatch {
    width: 16px;
    height: 16px;
    border: 1px solid #808080;
    cursor: pointer;
}

.color-swatch:hover {
    border: 1px solid #000;
    transform: scale(1.1);
}

/* Status Bar */
.status-bar {
    background: #ece9d8;
    border-top: 1px solid #fff;
    padding: 2px 5px;
    font-size: 11px;
    color: #000;
    display: flex;
    justify-content: space-between;
}

#coordinates {
    font-family: monospace;
}

/* Dialogs */
.dialog-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;
}

.dialog-overlay.active {
    display: flex;
}

.dialog-box {
    background: #ece9d8;
    border: 2px solid #0054e3;
    border-radius: 8px 8px 0 0;
    min-width: 300px;
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.3);
}

.dialog-title {
    background: linear-gradient(180deg,
        #0058ee 0%,
        #3a93ff 8%,
        #288eff 40%,
        #0058ee 88%,
        #004bd6 93%,
        #003db3 95%,
        #003db3 100%);
    color: white;
    padding: 5px 10px;
    font-size: 13px;
    font-weight: bold;
    border-radius: 6px 6px 0 0;
}

.dialog-content {
    padding: 20px;
    text-align: center;
}

.dialog-content p {
    margin: 5px 0;
    font-size: 12px;
}

.dialog-content input[type="text"],
.dialog-content input[type="number"] {
    padding: 5px;
    border: 1px solid #7f9db9;
    width: 100%;
    margin-bottom: 10px;
}

.dialog-content input[type="color"] {
    width: 100px;
    height: 50px;
    cursor: pointer;
}

.text-options {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 10px;
    font-size: 12px;
}

.text-options label {
    display: flex;
    align-items: center;
    gap: 5px;
}

.dialog-buttons {
    padding: 10px 20px 15px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.dialog-btn {
    padding: 5px 25px;
    background: #ece9d8;
    border: 1px solid #003c74;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.dialog-btn:hover {
    background: #c1d2ee;
}

.dialog-btn:active {
    background: #98b4e2;
}

/* Edit Colors Dialog (MS Paint Style) */
.color-dialog-box {
    min-width: auto;
    width: auto;
}

.color-dialog-content {
    display: flex;
    padding: 15px;
    gap: 15px;
}

.color-dialog-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.color-dialog-right {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-left: 15px;
    border-left: 1px solid #808080;
}

.color-section-label {
    font-size: 11px;
    color: #000;
}

.basic-colors-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 3px;
    background: #fff;
    border: 2px solid;
    border-color: #808080 #fff #fff #808080;
}

.basic-color-swatch {
    width: 18px;
    height: 18px;
    border: 1px solid #808080;
    cursor: pointer;
}

.basic-color-swatch:hover {
    border: 2px solid #000;
}

.basic-color-swatch.selected {
    border: 2px solid #000;
    box-shadow: inset 0 0 0 1px #fff;
}

.custom-colors-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 3px;
    background: #fff;
    border: 2px solid;
    border-color: #808080 #fff #fff #808080;
}

.custom-color-slot {
    width: 18px;
    height: 18px;
    border: 1px solid #808080;
    cursor: pointer;
    background: #fff;
}

.custom-color-slot:hover {
    border: 2px solid #000;
}

.custom-color-slot.selected {
    border: 2px solid #000;
    box-shadow: inset 0 0 0 1px #fff;
}

/* Color Spectrum Area */
.color-picker-row {
    display: flex;
    gap: 10px;
}

.color-spectrum-container {
    position: relative;
    width: 180px;
    height: 180px;
}

#color-spectrum {
    border: 1px solid #808080;
    cursor: crosshair;
}

.spectrum-crosshair {
    position: absolute;
    width: 10px;
    height: 10px;
    border: 1px solid #000;
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 1px #fff;
}

.luminance-bar-container {
    position: relative;
    width: 30px;
    height: 180px;
}

#luminance-bar {
    border: 1px solid #808080;
    cursor: pointer;
}

.luminance-arrow {
    position: absolute;
    right: -8px;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-right: 8px solid #000;
    pointer-events: none;
    transform: translateY(-50%);
}

.color-preview-box {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
}

.color-preview {
    width: 50px;
    height: 30px;
    border: 2px solid;
    border-color: #808080 #fff #fff #808080;
    background: #000;
}

.color-values {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
}

.color-value-row {
    display: flex;
    align-items: center;
    gap: 5px;
}

.color-value-row label {
    width: 40px;
    text-align: right;
}

.color-value-row input {
    width: 45px;
    padding: 2px 4px;
    border: 1px solid #7f9db9;
    font-size: 11px;
}

.add-custom-btn {
    font-size: 11px;
    padding: 4px 8px;
    background: #ece9d8;
    border: 1px solid #003c74;
    border-radius: 3px;
    cursor: pointer;
    margin-top: 5px;
}

.add-custom-btn:hover {
    background: #c1d2ee;
}

/* Scrollbar Styling (Windows XP style) */
::-webkit-scrollbar {
    width: 17px;
    height: 17px;
}

::-webkit-scrollbar-track {
    background: #ece9d8;
    border: 1px solid #999;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #ece9d8 0%, #d4d0c8 50%, #ece9d8 100%);
    border: 1px solid #999;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, #f0f0f0 0%, #e0e0e0 50%, #f0f0f0 100%);
}

::-webkit-scrollbar-button {
    background: #ece9d8;
    border: 1px solid #999;
    width: 17px;
    height: 17px;
}
