/* Custom Handwriting Fonts */
@font-face {
    font-family: 'Caveat';
    src: url('../fonts/Caveat-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    unicode-range: U+0000-00FF, U+0100-017F, U+0180-024F;
}

@font-face {
    font-family: 'Dancing Script';
    src: url('../fonts/DancingScript-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    unicode-range: U+0000-00FF, U+0100-017F, U+0180-024F;
}

@font-face {
    font-family: 'Pacifico';
    src: url('../fonts/Pacifico-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    unicode-range: U+0000-00FF, U+0100-017F, U+0180-024F;
}

@font-face {
    font-family: 'Kalam';
    src: url('../fonts/Kalam-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    unicode-range: U+0000-00FF, U+0100-017F, U+0180-024F;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f7f3f0;
    color: #3e2723;
    line-height: 1.6;
}

/* Main Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: white;
    color: #3e2723;
    padding: 30px;
    margin-bottom: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.08);
    border-bottom: 1px solid #e4d5b7;
}

.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.logo {
    width: 60px;
    height: 60px;
    border-radius: 12px;
}

.brand-text {
    text-align: left;
}

.brand-text h1 {
    font-size: 2.2em;
    margin-bottom: 5px;
    font-weight: 600;
    color: #3e2723;
}

.brand-text p {
    color: #5d4037;
    font-size: 1em;
    margin: 0;
}

header h1 {
    font-size: 24px;
    font-weight: 600;
}

header p {
    font-size: 14px;
    color: #5d4037;
    margin-top: 5px;
}

header .subtitle {
    color: #5d4037;
    font-size: 1em;
    margin-top: 10px;
}

/* Controls Section */
.controls {
    background: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.08);
    border: 1px solid #e4d5b7;
}

.control-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    font-weight: 500;
    font-size: 14px;
    color: #555;
    min-width: 100px;
}

.control-group select,
.control-group input[type="color"],
.control-group input[type="number"] {
    padding: 8px 12px;
    border: 1px solid #e4d5b7;
    border-radius: 6px;
    font-size: 14px;
    background: #fdfcfb;
}

.control-group select:focus,
.control-group input[type="number"]:focus {
    outline: none;
    border-color: #8d6e63;
    box-shadow: 0 0 0 3px rgba(141, 110, 99, 0.1);
    background: white;
}

.control-group select {
    min-width: 200px;
    cursor: pointer;
}

.control-group input[type="color"] {
    width: 50px;
    height: 38px;
    cursor: pointer;
    border: 1px solid #ddd;
}

.control-group input[type="number"] {
    width: 80px;
}

.control-group input[type="file"] {
    font-size: 14px;
}

/* Button Styles */
button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: #8d6e63;
    color: white;
}

button:hover {
    background: #6d4c41;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

button:active {
    transform: translateY(0);
}

button.secondary {
    background: #a0522d;
}

button.secondary:hover {
    background: #8b4513;
}

button.danger {
    background: #ff8a65;
}

button.danger:hover {
    background: #ff7043;
}

button.success {
    background: #689f38;
}

button.success:hover {
    background: #558b2f;
}

button:disabled {
    background: #e4d5b7;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

/* Toolbar */
.toolbar {
    background: white;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.08);
    border: 1px solid #e4d5b7;
}

.toolbar-section {
    margin-bottom: 15px;
}

.toolbar-section:last-child {
    margin-bottom: 0;
}

.toolbar-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.button-group button {
    padding: 8px 16px;
    font-size: 13px;
}

/* Editor Section */
.editor-section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.08);
    border: 1px solid #e4d5b7;
    margin-bottom: 20px;
}

.canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fafafa;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 20px;
    position: relative;
}

.canvas-wrapper {
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    position: relative;
    display: inline-block;
    line-height: 0;
    margin-left: 30px;
    margin-top: 30px;
}

/* Fix Fabric.js container spacing */
.canvas-wrapper .canvas-container {
    line-height: 0;
    font-size: 0;
    display: inline-block;
}

/* Canvas border to show label dimensions */
canvas {
    border: 1px solid #ccc;
    display: block;
}

/* Ruler Styles */
.ruler-container {
    position: relative;
    display: inline-block;
}

.ruler-horizontal {
    position: absolute;
    top: -30px;
    left: 30px;
    height: 30px;
    background: #f0f0f0;
    border-bottom: 1px solid #999;
    display: flex;
    align-items: flex-end;
}

.ruler-vertical {
    position: absolute;
    left: -30px;
    top: 30px;
    width: 30px;
    background: #f0f0f0;
    border-right: 1px solid #999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.ruler-mark {
    position: absolute;
    background: #666;
}

.ruler-horizontal .ruler-mark {
    width: 1px;
    height: 8px;
    bottom: 0;
}

.ruler-horizontal .ruler-mark.major {
    height: 12px;
    background: #333;
}

.ruler-horizontal .ruler-label {
    position: absolute;
    bottom: 12px;
    font-size: 9px;
    color: #333;
    transform: translateX(-50%);
    font-family: Arial, sans-serif;
    line-height: 1;
}

.ruler-vertical .ruler-mark {
    height: 1px;
    width: 8px;
    right: 0;
}

.ruler-vertical .ruler-mark.major {
    width: 12px;
    background: #333;
}

.ruler-vertical .ruler-label {
    position: absolute;
    right: 12px;
    font-size: 9px;
    color: #333;
    transform: translateY(-50%);
    font-family: Arial, sans-serif;
    line-height: 1;
}

.ruler-corner {
    position: absolute;
    top: -30px;
    left: -30px;
    width: 30px;
    height: 30px;
    background: #e0e0e0;
    border-right: 1px solid #999;
    border-bottom: 1px solid #999;
}

/* Export Section */
.export-section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.08);
    border: 1px solid #e4d5b7;
    text-align: center;
}

.export-section button {
    font-size: 16px;
    padding: 12px 30px;
    background: #689f38;
}

.export-section button:hover {
    background: #558b2f;
}

.export-info {
    margin-top: 15px;
    padding: 15px;
    background: #fff3e0;
    border-radius: 8px;
    border: 1px solid #e4d5b7;
    font-size: 14px;
    color: #5d4037;
}

/* Property Panel */
.property-panel {
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.08);
    border: 1px solid #e4d5b7;
    margin-bottom: 20px;
}

.property-panel h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #555;
}

.property-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.property-row label {
    min-width: 80px;
    font-size: 14px;
    color: #666;
}

/* Text Format Buttons */
.text-format-buttons {
    display: flex;
    gap: 8px;
}

.format-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    background: white;
    border: 2px solid #e4d5b7;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    color: #3e2723;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.format-btn:hover {
    background: #f7f3f0;
    border-color: #8d6e63;
    transform: translateY(-1px);
}

.format-btn.active {
    background: #8d6e63;
    border-color: #6d4c41;
    color: white;
}

.format-btn strong,
.format-btn em,
.format-btn u {
    font-style: normal;
    text-decoration: none;
    font-weight: bold;
}

.format-btn em {
    font-style: italic;
}

.format-btn u {
    text-decoration: underline;
}

/* Loading Indicator */
.loading {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.loading.active {
    display: flex;
}

.loading-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #8d6e63;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Footer Branding */
.footer-branding {
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    border-top: 1px solid #e4d5b7;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.08);
    color: #5d4037;
    font-size: 0.85em;
}

.footer-branding .logo-small {
    width: 20px;
    height: 20px;
    background: #8d6e63;
    border-radius: 4px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
    color: white;
    font-size: 12px;
    line-height: 20px;
    font-weight: bold;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 20px;
    }

    .logo-section {
        flex-direction: column;
        gap: 10px;
    }

    .brand-text {
        text-align: center;
    }

    .control-group {
        flex-direction: column;
        align-items: flex-start;
    }

    .control-group label {
        min-width: auto;
    }

    .control-group select {
        width: 100%;
    }

    .button-group {
        width: 100%;
    }

    .button-group button {
        flex: 1;
        min-width: 100px;
    }
}

/* Hidden file input */
#imageUploadInput {
    display: none;
}

/* Info box */
.info-box {
    background: #fff3e0;
    border-left: 4px solid #a0522d;
    padding: 12px 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    border: 1px solid #e4d5b7;
    font-size: 14px;
    color: #5d4037;
}

/* Grid layout for two-column layout on desktop */
@media (min-width: 1024px) {
    .main-layout {
        display: grid;
        grid-template-columns: 300px 1fr;
        gap: 20px;
    }

    .sidebar {
        grid-column: 1;
    }

    .main-content {
        grid-column: 2;
    }
}
