@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;500;600;700;800&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #1e5aa8;
    --secondary-color: #e82a1f;
    --tertiary-color: #276738;
    --bg-color: #f0f2f5;
    --white: #fefefe;
    --black: #1f2937;
}

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

body {
    font-family: 'Barlow Condensed', 'IBM Plex Sans', sans-serif;
    background: var(--bg-color);
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.header {
    padding: 10px 20px;
    background: var(--white);
    display: flex;
    align-items: center;
}

.header-image {
    height: auto;
    width: 15rem;
    margin-top: 20px;
    margin-bottom: 5px;
    margin-left: -0.3rem;
}

.toolbar {
    background: var(--white);
    padding: 12px 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    gap: 12px;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tool-btn, .export-btn, .clear-btn, .action-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--tertiary-color);
    background: var(--white);
    border-radius: 0px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tool-btn:hover, .export-btn:hover, .clear-btn:hover, .action-btn:hover {
    background: rgba(77, 125, 186, 0.15);
    border-color: #182B5c;
}

.tool-btn.active {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.export-btn {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
    margin-left: auto;
}

.clear-btn {
    background: #f8f9fa;
    color: var(--black);
    border-color: #6c757d;
    margin-left: 24px;
}

.clear-btn:hover {
    background: #e9ecef;
    border-color: #5a6268;
}

.action-btn {
    margin-left: 24px;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e9ecef;
    color: #6c757d;
    border-color: #dee2e6;
}

.action-btn:disabled:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

.export-btn:hover {
    background: #8F2421;
}

/* Canvas Mode Toggle */
.mode-toggle-container {
    margin-left: auto;
    margin-right: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-toggle {
    display: flex;
    border: 1px solid var(--tertiary-color);
    border-radius: 0px;
    overflow: hidden;
}

.mode-btn {
    padding: 8px 16px;
    border: none;
    background: var(--white);
    color: var(--black);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    font-family: inherit;
    border-right: 1px solid var(--tertiary-color);
}

.mode-btn:last-child {
    border-right: none;
}

.mode-btn:hover {
    background: rgba(77, 125, 186, 0.15);
}

.mode-btn.active {
    background: var(--primary-color);
    color: var(--white);
    font-weight: 500;
}

/* Page Controls */
.page-controls {
    display: flex;
    gap: 4px;
}

.page-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--tertiary-color);
    background: var(--white);
    border-radius: 0px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 14px;
}

.page-btn:hover:not(:disabled) {
    background: rgba(77, 125, 186, 0.15);
    border-color: #182B5c;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f8f9fa;
    color: #6c757d;
    border-color: #dee2e6;
}

.page-btn:disabled:hover {
    background: #f8f9fa;
    border-color: #dee2e6;
}

.page-indicator {
    font-size: 12px;
    color: var(--black);
    margin-left: 8px;
    font-family: inherit;
    font-weight: 500;
}

.canvas-container {
    flex: 1;
    overflow: auto;
    padding: 10px 20px 20px 20px;
    position: relative;
}

/* Mode-specific visual feedback */
.canvas-container.canvas-mode {
    background: var(--bg-color);
}

.canvas-container.notebook-mode {
    background: #f0f2f5;
    text-align: center;
}

.canvas-container.notebook-mode #canvas {
    display: block;
    margin: 5px auto 0 auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2), 0 8px 24px rgba(0,0,0,0.1);
    position: relative;
}

/* Page boundaries are now drawn directly on the canvas */

#canvas {
    border: 1px solid #ddd;
    background: var(--white);
    border-radius: 0px;
    cursor: crosshair;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    /* Touch support for tablets and stylus */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

#canvas.text-mode {
    cursor: text;
}

/* Custom Tooltips */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--black);
    color: var(--white);
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 2px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s ease-in-out;
    z-index: 1000;
    margin-bottom: 5px;
}

.tooltip:hover::after {
    opacity: 1;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 1.5rem;
}

.modal-content p {
    margin: 10px 0;
    color: var(--black);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.modal-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: background-color 0.2s;
}

.modal-btn.primary {
    background: var(--primary-color);
    color: white;
}

.modal-btn.primary:hover {
    background: #164a8a;
}

.modal-btn.secondary {
    background: #e0e0e0;
    color: #333;
}

.modal-btn.secondary:hover {
    background: #d0d0d0;
}

.modal-hint {
    display: block;
    margin-top: 15px;
    color: #666;
    font-size: 12px;
    line-height: 1.4;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

#loadingMessage {
    margin-top: 20px;
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

/* Toast Notification System */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
    max-width: 300px;
}

.toast.success {
    background: #4caf50;
}

.toast.error {
    background: #f44336;
}

.toast.info {
    background: var(--primary-color);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design - Mobile Support */
@media (max-width: 768px) {
    .modal-content {
        max-width: 90%;
        padding: 20px;
    }

    .modal-buttons {
        flex-direction: column;
    }

    .modal-btn {
        min-width: 100%;
    }

    .toast-container {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    .toast {
        max-width: 100%;
    }
}