/* --- General & Shared Styles --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px 0; /* Add some padding for smaller viewports */
    box-sizing: border-box;
    background-color: #f4f4f9;
    color: #333;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    text-align: center;
    background-color: #fff;
    padding: 20px 40px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 90%;
    transition: background-color 0.3s;
}

/* MODIFIED: Add specific max-widths for each page context */
.index-page .container {
    max-width: 500px;
}

.doodle-page .container {
    max-width: 900px;
}


/* --- Index Page Styles --- */
#main-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px; /* This adds a nice space between the two boxes */
    width: 100%;
    align-items: center; /* Ensures boxes are centered within the wrapper */
}

.container a.button { 
    display: inline-block; 
    background-color: #007bff; 
    color: white; 
    padding: 15px 30px; 
    text-decoration: none; 
    border-radius: 5px; 
    font-size: 1.2em; 
    margin-bottom: 20px; 
}

.container form { 
    margin-top: 20px; 
}

.container input[type="text"] { 
    padding: 10px; 
    width: 250px; 
    border: 1px solid #ccc; 
    border-radius: 5px; 
}

.container input[type="submit"] { 
    padding: 10px 20px; 
    background-color: #28a745; 
    color: white; 
    border: none; 
    border-radius: 5px; 
    cursor: pointer; 
}

.error-message { 
    color: #c00; 
    margin-top: 10px; 
    display: none; 
}


/* --- Doodle Page Styles --- */
/* Dark Mode */
body.dark-mode {
    background-color: #121212;
    color: #eee;
}

body.dark-mode .container {
    background-color: #1e1e1e;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

body.dark-mode button {
    background-color: #333;
    color: #eee;
    border: 1px solid #555;
}

body.dark-mode button:hover {
    background-color: #444;
}

body.dark-mode input[type="text"],
body.dark-mode select {
    background-color: #333;
    color: #eee;
    border: 1px solid #555;
}

/* Typography & Header */
body.dark-mode h1 { color: #ddd; }

p {
    margin-top: 0;
    color: #666;
}
body.dark-mode p { color: #aaa; }

.doodle-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.copy-controls {
    display: flex;
    gap: 8px; /* Adds a small space between the buttons */
}

.copy-btn {
    padding: 4px 10px; /* Slightly more padding */
    font-size: 0.8em;
    cursor: pointer;
    border: 1px solid #ccc;
    background-color: #f0f0f0;
    border-radius: 4px;
}

body.dark-mode .copy-btn {
    background-color: #444;
    border-color: #666;
    color: #eee;
}

/* Canvas */
.canvas-container {
    margin: 15px auto;
    border: 2px solid #ccc;
    border-radius: 8px;
    overflow: hidden;
    display: inline-block;
    line-height: 0;
}

canvas {
    background-color: #fff;
    max-width: 100%;
    height: auto;
    display: block;
}

/* Controls */
.control-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: bold;
}

.drawing-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
}
body.dark-mode .drawing-controls {
    border-bottom-color: #333;
}

.action-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Buttons */
button {
    padding: 10px 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #fff;
    color: #333;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: all 0.2s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* --- Coloured Button Styles --- */
#undo-btn, #redo-btn { background-color: #e6f2ff; border-color: #b3d9ff; color: #0052cc; }
#undo-btn:hover, #redo-btn:hover { background-color: #d9eaff; }
body.dark-mode #undo-btn, body.dark-mode #redo-btn { background-color: #2a3d59; border-color: #4a6b99; color: #cce0ff; }
body.dark-mode #undo-btn:hover, body.dark-mode #redo-btn:hover { background-color: #385073; }

#clear-btn { background-color: #ffebe6; border-color: #ffc2b3; color: #c00; }
#clear-btn:hover { background-color: #ffddd4; }
body.dark-mode #clear-btn { background-color: #592a2a; border-color: #994a4a; color: #ffcccc; }
body.dark-mode #clear-btn:hover { background-color: #733838; }

#bg-toggle-btn { background-color: #e6e6e6; border-color: #ccc; color: #333; }
#bg-toggle-btn:hover { background-color: #d9d9d9; }
body.dark-mode #bg-toggle-btn { background-color: #4d4d4d; border-color: #666; color: #eee; }
body.dark-mode #bg-toggle-btn:hover { background-color: #595959; }

#export-btn { background-color: #e6fff2; border-color: #b3ffda; color: #006644; }
#export-btn:hover { background-color: #d9ffe9; }
body.dark-mode #export-btn { background-color: #2a593d; border-color: #4a996b; color: #ccffdd; }
body.dark-mode #export-btn:hover { background-color: #387350; }

#quit-btn { background-color: #f5e6e6; border-color: #e0b3b3; color: #800; }
#quit-btn:hover { background-color: #ebd9d9; }
body.dark-mode #quit-btn { background-color: #4d2a2a; border-color: #804a4a; color: #ffcccc; }
body.dark-mode #quit-btn:hover { background-color: #663838; }

#eraser-btn { background-color: #f2e6ff; border-color: #d9b3ff; color: #5e00cc; }
#eraser-btn:hover { background-color: #e9d9ff; }
#eraser-btn.active { background-color: #d9b3ff; box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); }
body.dark-mode #eraser-btn { background-color: #3d2a59; border-color: #6b4a99; color: #e0ccff; }
body.dark-mode #eraser-btn:hover { background-color: #503873; }
body.dark-mode #eraser-btn.active { background-color: #6b4a99; }

/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: #fff;
    padding: 25px 35px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    margin-top: 0;
    color: #333;
}

.modal-content p {
    margin-bottom: 25px;
    color: #666;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.modal-btn {
    padding: 10px 25px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

#modal-cancel-btn {
    background-color: #e6e6e6;
    color: #333;
}
#modal-cancel-btn:hover {
    background-color: #d9d9d9;
}

#modal-confirm-btn {
    background-color: #c00;
    color: #fff;
}
#modal-confirm-btn:hover {
    background-color: #a00;
}

/* Dark Mode for Modal */
body.dark-mode .modal-content {
    background-color: #2a2a2a;
    border: 1px solid #444;
}
body.dark-mode .modal-content h2 {
    color: #eee;
}
body.dark-mode .modal-content p {
    color: #ccc;
}
body.dark-mode #modal-cancel-btn {
    background-color: #555;
    color: #eee;
}
body.dark-mode #modal-cancel-btn:hover {
    background-color: #666;
}
body.dark-mode #modal-confirm-btn {
    background-color: #d93030;
}
body.dark-mode #modal-confirm-btn:hover {
    background-color: #e04f4f;
}

/* Styles for the Terms & Conditions box on the index page */
#terms-box {
    text-align: center;
    font-size: 0.9em;
    color: #555;
    padding-top: 20px;
    padding-bottom: 20px;
}

#terms-box p {
    margin: 0 0 1em 0;
}

#terms-box .copyright {
    font-weight: bold;
    margin-bottom: 0.5em;
}

#terms-box a {
    color: #007bff;
    text-decoration: none;
}

#terms-box a:hover {
    text-decoration: underline;
}

/* Dark mode adjustments for terms box */
body.dark-mode #terms-box {
    color: #bbb;
}

body.dark-mode #terms-box a {
    color: #58a6ff;
}

/* --- Modal Styles --- */
.modal-overlay {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px 30px;
    border: 1px solid #888;
    width: 90%;
    max-width: 400px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.modal-content h2 {
    margin-top: 0;
}

.modal-buttons {
    margin-top: 20px;
    display: flex;
    justify-content: space-around;
}

.button-secondary {
    background-color: #6c757d;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
}

.button-secondary:hover {
    background-color: #5a6268;
}
